<?php
/**
 * @Author: king
 * @Date:   2019-02-17 19:50:25
 * @Last Modified by:   king
 * @Last Modified time: 2019-04-24 20:44:38
 */

namespace App\Tools;
use App\Tools\Astrolog\Astrolog;
//use App\Models\Api\Astrolog;
use App\Models\Api\Solarterms;


/**
 * 八字类库
 * Class HoroscopeData
 * @package App\Tools\Astrolog\Astrolog
 */
class HoroscopeData
{
    public static $_instance;
    /**
     * 八字相关的参数信息
     * @var array
     * time_type int 时间类型 [0=>北京时间,1=>真太阳时]
     * time_start int 日辰初始 [0 => 24点,23=>子时]
     * recode array 用户的档案信息
     *  id 档案id
     *  uid 用户id
     *  name 用户档案名称
     *  type 用户性别/类别 [1=>男,2=>女]
     *  year 出生日期-年
     *  month 出生日期-月 1~12
     *  day 出生日期-日 1~
     *  hour 出生日期-小时 0~23
     *  minute 出生日期-分钟 0~59
     *  timezone 出生日期-时区 -12~12
     *  birth_country 出生地址-省
     *  birth_province 出生地址-市
     *  birth_city 出生地址-区
     *  live_country 现居地址-省
     *  live_province 现居地址-市
     *  live_city 现居地址-区
     *  comments 标签：自己，朋友，案例...
     *  isself 是否自己 [0=>否,1=>是自己的档案]
     *  long_deg 出生地-经度-度 0~180
     *  long_min 出生地-经度-分 0~59
     *  ew -1=>西经,1=>东经
     *  lat_deg 出生地-纬度-度 0~90
     *  lat_min 出生地-纬度-分 0~59
     *  ns -1=>南纬,1=>北纬
     *  avatar 档案头像
     *  status 档案状态 1=>正常
     *  from 档案来源 zhunle=>app内添加的档案
     *  is_summer 是否为夏令时
     *  aid 档案的行星信息 链表字段
     * advance array
     *  year 需要计算的年份
     */
    public $option = [
        'time_type' => 0,
        'time_start' => 23,
        'recode' => [],
        'advance' => [],
        'liunian_realtime' => false,
    ];
    /**
     * @var array
     * chinese_era 六十甲子
     * heavenly_stems 十天干
     * earthly_branches 十二地支
     * wuxing 天干的五行属性
     * wuxing_yinyang 五行阴阳
     * shishen 十神对照表
     * canggan 地支藏干表
     * shensha 神煞对照表
     * changsheng 长生十二宫对照表
     */
    protected $param = [
        'chinese_era' => [
            0 => '甲子',
            1 => '乙丑',
            2 => '丙寅',
            3 => '丁卯',
            4 => '戊辰',
            5 => '己巳',
            6 => '庚午',
            7 => '辛未',
            8 => '壬申',
            9 => '癸酉',
            10 => '甲戌',
            11 => '乙亥',
            12 => '丙子',
            13 => '丁丑',
            14 => '戊寅',
            15 => '己卯',
            16 => '庚辰',
            17 => '辛巳',
            18 => '壬午',
            19 => '癸未',
            20 => '甲申',
            21 => '乙酉',
            22 => '丙戌',
            23 => '丁亥',
            24 => '戊子',
            25 => '己丑',
            26 => '庚寅',
            27 => '辛卯',
            28 => '壬辰',
            29 => '癸巳',
            30 => '甲午',
            31 => '乙未',
            32 => '丙申',
            33 => '丁酉',
            34 => '戊戌',
            35 => '己亥',
            36 => '庚子',
            37 => '辛丑',
            38 => '壬寅',
            39 => '癸卯',
            40 => '甲辰',
            41 => '乙巳',
            42 => '丙午',
            43 => '丁未',
            44 => '戊申',
            45 => '己酉',
            46 => '庚戌',
            47 => '辛亥',
            48 => '壬子',
            49 => '癸丑',
            50 => '甲寅',
            51 => '乙卯',
            52 => '丙辰',
            53 => '丁巳',
            54 => '戊午',
            55 => '己未',
            56 => '庚申',
            57 => '辛酉',
            58 => '壬戌',
            59 => '癸亥',
        ],
        'heavenly_stems' => ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"],
        'earthly_branches' => ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"],
        'wuxing' => [
            '甲' => '木',
            '乙' => '木',
            '丙' => '火',
            '丁' => '火',
            '戊' => '土',
            '己' => '土',
            '庚' => '金',
            '辛' => '金',
            '壬' => '水',
            '癸' => '水',
        ],
        'wuxing_yinyang' => [
            '甲' => 0,
            '乙' => 1,
            '丙' => 0,
            '丁' => 1,
            '戊' => 0,
            '己' => 1,
            '庚' => 0,
            '辛' => 1,
            '壬' => 0,
            '癸' => 1,
        ],
        'shishen' => [
            '甲' => [
                '甲' => '比肩',
                '乙' => '劫财',
                '丙' => '偏印',
                '丁' => '正印',
                '戊' => '七杀',
                '己' => '正官',
                '庚' => '偏财',
                '辛' => '正财',
                '壬' => '食神',
                '癸' => '伤官',
            ],
            '乙' => [
                '甲' => '劫财',
                '乙' => '比肩',
                '丙' => '正印',
                '丁' => '偏印',
                '戊' => '正官',
                '己' => '七杀',
                '庚' => '正财',
                '辛' => '偏财',
                '壬' => '伤官',
                '癸' => '食神',
            ],
            '丙' => [
                '甲' => '食神',
                '乙' => '伤官',
                '丙' => '比肩',
                '丁' => '劫财',
                '戊' => '偏印',
                '己' => '正印',
                '庚' => '七杀',
                '辛' => '正官',
                '壬' => '偏财',
                '癸' => '正财',
            ],
            '丁' => [
                '甲' => '伤官',
                '乙' => '食神',
                '丙' => '劫财',
                '丁' => '比肩',
                '戊' => '正印',
                '己' => '偏印',
                '庚' => '正官',
                '辛' => '七杀',
                '壬' => '正财',
                '癸' => '偏财',
            ],
            '戊' => [
                '甲' => '偏财',
                '乙' => '正财',
                '丙' => '食神',
                '丁' => '伤官',
                '戊' => '比肩',
                '己' => '劫财',
                '庚' => '偏印',
                '辛' => '正印',
                '壬' => '七杀',
                '癸' => '正官',
            ],
            '己' => [
                '甲' => '正财',
                '乙' => '偏财',
                '丙' => '伤官',
                '丁' => '食神',
                '戊' => '劫财',
                '己' => '比肩',
                '庚' => '正印',
                '辛' => '偏印',
                '壬' => '正官',
                '癸' => '七杀',
            ],
            '庚' => [
                '甲' => '七杀',
                '乙' => '正官',
                '丙' => '偏财',
                '丁' => '正财',
                '戊' => '食神',
                '己' => '伤官',
                '庚' => '比肩',
                '辛' => '劫财',
                '壬' => '偏印',
                '癸' => '正印',
            ],
            '辛' => [
                '甲' => '正官',
                '乙' => '七杀',
                '丙' => '正财',
                '丁' => '偏财',
                '戊' => '伤官',
                '己' => '食神',
                '庚' => '劫财',
                '辛' => '比肩',
                '壬' => '正印',
                '癸' => '偏印',
            ],
            '壬' => [
                '甲' => '偏印',
                '乙' => '正印',
                '丙' => '七杀',
                '丁' => '正官',
                '戊' => '偏财',
                '己' => '正财',
                '庚' => '食神',
                '辛' => '伤官',
                '壬' => '比肩',
                '癸' => '劫财',
            ],
            '癸' => [
                '甲' => '正印',
                '乙' => '偏印',
                '丙' => '正官',
                '丁' => '七杀',
                '戊' => '正财',
                '己' => '偏财',
                '庚' => '伤官',
                '辛' => '食神',
                '壬' => '劫财',
                '癸' => '比肩',
            ],
        ],
        'canggan' => [
            '亥' => ['壬', '甲'],
            '子' => ['癸'],
            '丑' => ['己', '癸', '辛'],
            '寅' => ['甲', '丙', '戊'],
            '卯' => ['乙'],
            '辰' => ['戊', '乙', '癸'],
            '巳' => ['丙', '戊', '庚'],
            '午' => ['丁', '己',],
            '未' => ['己', '丁', '乙'],
            '申' => ['庚', '壬', '戊'],
            '酉' => ['辛'],
            '戌' => ['戊', '丁', '辛']
        ],
        'shensha' => [
            '华盖' => [
                '寅' => '戌',
                '午' => '戌',
                '戌' => '戌',
                '亥' => '未',
                '卯' => '未',
                '未' => '未',
                '申' => '辰',
                '子' => '辰',
                '辰' => '辰',
                '巳' => '丑',
                '酉' => '丑',
                '丑' => '丑',
            ],
            '桃花' => [
                '寅' => '卯',
                '午' => '卯',
                '戌' => '卯',
                '亥' => '子',
                '卯' => '子',
                '未' => '子',
                '申' => '酉',
                '子' => '酉',
                '辰' => '酉',
                '巳' => '午',
                '酉' => '午',
                '丑' => '午',
            ],
            '驿马' => [
                '寅' => '申',
                '午' => '申',
                '戌' => '申',
                '亥' => '巳',
                '卯' => '巳',
                '未' => '巳',
                '申' => '寅',
                '子' => '寅',
                '辰' => '寅',
                '巳' => '亥',
                '酉' => '亥',
                '丑' => '亥',
            ],
            '亡神' => [
                '寅' => '巳',
                '午' => '巳',
                '戌' => '巳',
                '亥' => '寅',
                '卯' => '寅',
                '未' => '寅',
                '申' => '亥',
                '子' => '亥',
                '辰' => '亥',
                '巳' => '申',
                '酉' => '申',
                '丑' => '申',
            ],
            '将星' => [
                '寅' => '午',
                '午' => '午',
                '戌' => '午',
                '亥' => '卯',
                '卯' => '卯',
                '未' => '卯',
                '申' => '子',
                '子' => '子',
                '辰' => '子',
                '巳' => '酉',
                '酉' => '酉',
                '丑' => '酉',
            ],

            '天乙贵人' => [
                '甲' => ['丑', '未'],
                '乙' => ['子', '申'],
                '丙' => ['酉', '亥'],
                '丁' => ['酉', '亥'],
                '戊' => ['丑', '未'],
                '己' => ['子', '申'],
                '庚' => ['丑', '未'],
                '辛' => ['寅', '午'],
                '壬' => ['巳', '卯'],
                '癸' => ['巳', '卯'],
            ],
            '天德贵人' => [
                '寅' => '丁',
                '卯' => '申',
                '辰' => '壬',
                '巳' => '辛',
                '午' => '亥',
                '未' => '甲',
                '申' => '癸',
                '酉' => '寅',
                '戌' => '丙',
                '亥' => '乙',
                '子' => '巳',
                '丑' => '庚',
            ],
            '文昌贵人' => [
                '甲' => '巳',
                '乙' => '午',
                '丙' => '申',
                '丁' => '酉',
                '戊' => '申',
                '己' => '酉',
                '庚' => '亥',
                '辛' => '子',
                '壬' => '寅',
                '癸' => '卯',
            ],
            '月德贵人' => [
                '申' => '壬',
                '子' => '壬',
                '辰' => '壬',
                '寅' => '丙',
                '午' => '丙',
                '戌' => '丙',
                '巳' => '庚',
                '酉' => '庚',
                '丑' => '庚',
                '亥' => '甲',
                '卯' => '甲',
                '未' => '甲',
            ],
            '金舆' => [
                '甲' => '辰',
                '乙' => '巳',
                '丙' => '未',
                '丁' => '申',
                '戊' => '未',
                '己' => '申',
                '庚' => '戌',
                '辛' => '亥',
                '壬' => '丑',
                '癸' => '寅',
            ],
            '红艳煞' => [
                '甲' => '午',
                '乙' => '申',
                '丙' => '寅',
                '丁' => '未',
                '戊' => '辰',
                '己' => '辰',
                '庚' => '申',
                '辛' => '酉',
                '壬' => '子',
                '癸' => '戌',
            ],
            '孤辰' => [
                '亥' => '寅',
                '子' => '寅',
                '丑' => '寅',
                '寅' => '巳',
                '卯' => '巳',
                '辰' => '巳',
                '巳' => '申',
                '午' => '申',
                '未' => '申',
                '申' => '亥',
                '酉' => '亥',
                '戌' => '亥',
            ],
            '寡宿' => [
                '亥' => '戌',
                '子' => '戌',
                '丑' => '戌',
                '寅' => '丑',
                '卯' => '丑',
                '辰' => '丑',
                '巳' => '辰',
                '午' => '辰',
                '未' => '辰',
                '申' => '未',
                '酉' => '未',
                '戌' => '未',
            ],
            '禄神' => [
                '甲' => '寅',
                '乙' => '卯',
                '丙' => '巳',
                '丁' => '午',
                '戊' => '巳',
                '己' => '午',
                '庚' => '申',
                '辛' => '酉',
                '壬' => '亥',
                '癸' => '子',
            ],
            '羊刃' => [
                '甲' => '卯',
                '乙' => '辰',
                '丙' => '午',
                '丁' => '未',
                '戊' => '午',
                '己' => '未',
                '庚' => '酉',
                '辛' => '戌',
                '壬' => '子',
                '癸' => '丑',
            ],
            '金神' => [
                '癸酉', '己巳', '乙丑'
            ],
        ],
        'changsheng' => [
            '甲' => [
                '子' => '沐浴',
                '丑' => '冠带',
                '寅' => '临官',
                '卯' => '帝旺',
                '辰' => '衰',
                '巳' => '病',
                '午' => '死',
                '未' => '墓',
                '申' => '绝',
                '酉' => '胎',
                '戌' => '养',
                '亥' => '长生',
            ],
            '乙' => [
                '巳' => '沐浴',
                '辰' => '冠带',
                '卯' => '临官',
                '寅' => '帝旺',
                '丑' => '衰',
                '子' => '病',
                '亥' => '死',
                '戌' => '墓',
                '酉' => '绝',
                '申' => '胎',
                '未' => '养',
                '午' => '长生',
            ],
            '丙' => [
                '子' => '胎',
                '丑' => '养',
                '寅' => '长生',
                '卯' => '沐浴',
                '辰' => '冠带',
                '巳' => '临官',
                '午' => '帝旺',
                '未' => '衰',
                '申' => '病',
                '酉' => '死',
                '戌' => '墓',
                '亥' => '绝',
            ],
            '丁' => [
                '申' => '沐浴',
                '未' => '冠带',
                '午' => '临官',
                '巳' => '帝旺',
                '辰' => '衰',
                '卯' => '病',
                '寅' => '死',
                '丑' => '墓',
                '子' => '绝',
                '亥' => '胎',
                '戌' => '养',
                '酉' => '长生',
            ],
            '戊' => [
                '子' => '胎',
                '丑' => '养',
                '寅' => '长生',
                '卯' => '沐浴',
                '辰' => '冠带',
                '巳' => '临官',
                '午' => '帝旺',
                '未' => '衰',
                '申' => '病',
                '酉' => '死',
                '戌' => '墓',
                '亥' => '绝',
            ],
            '己' => [
                '申' => '沐浴',
                '未' => '冠带',
                '午' => '临官',
                '巳' => '帝旺',
                '辰' => '衰',
                '卯' => '病',
                '寅' => '死',
                '丑' => '墓',
                '子' => '绝',
                '亥' => '胎',
                '戌' => '养',
                '酉' => '长生',
            ],
            '庚' => [
                '午' => '沐浴',
                '未' => '冠带',
                '申' => '临官',
                '酉' => '帝旺',
                '戌' => '衰',
                '亥' => '病',
                '子' => '死',
                '丑' => '墓',
                '寅' => '绝',
                '卯' => '胎',
                '辰' => '养',
                '巳' => '长生',
            ],
            '辛' => [
                '亥' => '沐浴',
                '戌' => '冠带',
                '酉' => '临官',
                '申' => '帝旺',
                '未' => '衰',
                '午' => '病',
                '巳' => '死',
                '辰' => '墓',
                '卯' => '绝',
                '寅' => '胎',
                '丑' => '养',
                '子' => '长生',
            ],
            '壬' => [
                '酉' => '沐浴',
                '戌' => '冠带',
                '亥' => '临官',
                '子' => '帝旺',
                '丑' => '衰',
                '寅' => '病',
                '卯' => '死',
                '辰' => '墓',
                '巳' => '绝',
                '午' => '胎',
                '未' => '养',
                '申' => '长生',
            ],
            '癸' => [
                '寅' => '沐浴',
                '丑' => '冠带',
                '子' => '临官',
                '亥' => '帝旺',
                '戌' => '衰',
                '酉' => '病',
                '申' => '死',
                '未' => '墓',
                '午' => '绝',
                '巳' => '胎',
                '辰' => '养',
                '卯' => '长生',
            ],
        ],
    ];
    /**
     * 八字相关数据
     * @var array
     * bazi 当前生辰的八字
     * birth_time 出生时间戳
     * st_time 大运起运时间
     * dayun 大运信息
     */
    public $data = [
        'bazi' => null,
        'score' => ['金' => 0, '木' => 0, '水' => 0, '火' => 0, '土' => 0,],
        'wuxing_perc' => ['金' => 0, '木' => 0, '水' => 0, '火' => 0, '土' => 0,],
        'shishen_wuxing' => null,
        'lushen' => null,
        'birth_time' => null,
        'st_time' => null,
        'dayun' => null,
        'dayun_now' => null,
        'liunian_now' => null,
        'shenwang' => null,
        'liunianzhushen' => null,
        'ganzhibuxie' => null,
        'anjing' => null,
        'shuangchong' => null,
        'donggong' => null,
        'or_shanggong' => null,
        'or_shangshen' => null,
        'shanggong' => null,
        'shangshen' => null,
    ];

    private function __construct()
    {
    }

    /**
     * 获取静态实例对象
     * @param array $option
     * @return Horoscope
     */
    public static function getInstance($option = [])
    {
        if (!(self::$_instance instanceof self))
        {
            self::$_instance = new self();
        }
        if (!empty($option))
        {
            if (!empty($option['recode']))
            {
                self::$_instance->option['recode'] = $option['recode'];
                // 出生时间时间戳 存入 data
                self::$_instance->data['birth_time'] = strtotime($option['recode']['year'] . '-' . $option['recode']['month'] . '-' . $option['recode']['day'] . ' ' . $option['recode']['hour'] . ':' . $option['recode']['minute']);
            }
            if (!empty($option['advance']))
            {
                self::$_instance->option['advance'] = $option['advance'];
            }
            if (isset($option['time_type']) && $option['time_type'] === 1)
            {
                self::$_instance->option['time_type'] = 1;
            }
            if (isset($option['time_start']) && $option['time_start'] === 0)
            {
                self::$_instance->option['time_start'] = 0;
            }
        }
        if (!empty(self::$_instance->option['recode']))
        {
            // 获取命主太阳度数
            $sunDeg = Astrolog::getInstance()->setRecode1(self::$_instance->option['recode'])
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting(config('astroset.setting1'))
                    ->getPlanetOriginData('0')[0] * 1;
            //获取八字
            self::$_instance->getBazi(self::$_instance->data['birth_time'], $sunDeg, true);
        }
        return self::$_instance;
    }

    /**
     * @return array
     */
    public function yearConclusion()
    {
        $result = [];

        $this->getAllData();
        $this->getyearConclusionData();

        $topic = $this->getTopic();
        $point = $this->getPoint();

        $result['topic'] = $topic;
        $result['point'] = $point;

        return $result;
    }

    /**
     * 获取年运主题
     * @param array $dongshenSort
     * @param null $max_dongshen
     * @return integer
     */
    public function getTopic($dongshenSort = [], $max_dongshen = null)
    {
        $liu = $this->data['liunian_now'];
        $liu_benqi = $this->param['canggan'][$liu[1]][0];

        $bazi = $this->data['bazi'];

        $rigan = $bazi[5];

        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];
        $liuzhi_shishen = $this->param['shishen'][$liu_benqi][$rigan];

        /**
         * 折冲之年
         * 与大运或日柱双冲
         */
        $zhu_temp = [
            [$rigan, $bazi[6]],
        ];

        if ($this->data['dayun_now'] != null)
        {
            $zhu_temp[] = $this->data['dayun_now'];
        }
        if ($this->is_shuangchong($liu, $zhu_temp))
        {
            return 0;
        }

        /**
         * 缭乱之年
         * 与命运形成多组刑冲穿（三组以上）
         */
        $zhis = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];

        if ($this->data['dayun_now'] != null) $zhis[] = $this->data['dayun_now'][1];

        $xcc_num = 0;

        foreach ($zhis as $zhi)
        {
            if ($this->is_xing($zhi, $liu[1]) || $this->is_liuchong($zhi, $liu[1]) || $this->is_liuhai($zhi, $liu[1]))
            {
                $xcc_num++;
            }
        }
        if ($xcc_num >= 3)
        {
            return 1;
        }

        /**
         * 逆流之年
         * 与日柱干合支刑或干合支穿
         * 女，主神正官
         * 男，主神正官
         * 男，主神正财
         * 女，主神正财
         */
        if ($this->is_wuhe($rigan, $liu[0])
            && ($this->is_xing($bazi[6], $liu[1]) || $this->is_liuhai($bazi[6], $liu[1])))
        {
            // 男
            if ($this->option['recode']['type'] == 1)
            {
                if (in_array('正官', $this->data['liunianzhushen']))
                {
                    return 3;
                } elseif (in_array('正财', $this->data['liunianzhushen']))
                {
                    return 4;
                }
            } // 女
            else
            {
                if (in_array('正官', $this->data['liunianzhushen']))
                {
                    return 2;
                } elseif (in_array('正财', $this->data['liunianzhushen']))
                {
                    return 5;
                }
            }
        }
        $donggong = $this->data['donggong'];
        $dongshen = $this->data['dongshen'];

        $shanggong = $this->data['shanggong'];
        $shangshen = $this->data['shangshen'];

        $max_donggong = max($donggong);
        if (empty($dongshenSort))
        {
            $dongshenSort = $this->data['dongshen'];
            arsort($dongshenSort);
        }
        if ($max_dongshen === null)
        {
            $max_dongshen = array_shift($dongshenSort);
        }
        $is_yin_dongshen = $dongshen['正印'] > 0.5 || $dongshen['偏印'] > 0.5;
        $is_cai_dongshen = $dongshen['正财'] > 0.5 || $dongshen['偏财'] > 0.5;
        $is_sha_dongshen = $dongshen['正官'] > 0.5 || $dongshen['七杀'] > 0.5;
        $is_shi_dongshen = $dongshen['食神'] > 0.5 || $dongshen['伤官'] > 0.5;
        $y_zhi_benqi = $this->param['canggan'][$bazi[2]][0];

        $gan_bijie_num = 0;
        if (in_array($this->param['shishen'][$bazi[1]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;
        if (in_array($this->param['shishen'][$bazi[3]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;
        if (in_array($this->param['shishen'][$bazi[7]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;
        if ($this->data['dayun_now'] != null
            && in_array($this->param['shishen'][$this->data['dayun_now'][0]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;

        /**
         * 年宫最高且受伤
         * 母忧之年 此时印星也是动神（指数高于0.5）
         * 父忧之年 此时财星也是动神
         * 注：财印都动则优先受伤度高者
         */
        if ($this->data['donggong'][0] == $max_donggong && $shanggong[0] > 1)
        {
            // 母忧之年
            if ($is_yin_dongshen && !$is_cai_dongshen)
            {
                return 6;
            } // 父忧之年
            elseif (!$is_yin_dongshen && $is_cai_dongshen)
            {
                return 7;
            } // 财印都动
            elseif ($is_yin_dongshen && $is_cai_dongshen)
            {
                // 优先受伤度高者
                $shangs = [
                    $shangshen['正印'],
                    $shangshen['偏印'],
                    $shangshen['正财'],
                    $shangshen['偏财'],
                ];

                $max_shang = max($shangs);
                // 母忧之年
                if ($shangshen['正印'] == $max_shang || $shangshen['偏印'] == $max_shang)
                {
                    return 6;
                } // 父忧之年
                else
                {
                    return 7;
                }
            }
        }

        /**
         * 日宫最高且受伤
         * 情伤之年  女命，官杀也是动神；男命，财星也是动神
         * 思虑之年  正印或食神受伤
         * 磨炼之年  七杀为最高动神，且，如七杀透出天干未被合
         * 晦名之年  男命，正官受伤
         * 劳身之年  禄受伤
         */
        if ($this->data['donggong'][2] == $max_donggong && $shanggong[2] >= 1)
        {
            // 情伤之年
            if (($this->option['recode']['type'] == 1 && $is_cai_dongshen)
                || ($this->option['recode']['type'] != 1 && $is_sha_dongshen))
            {
                return 8;
            }
            // 思虑之年
            if ($shangshen['正印'] > 1 || $shangshen['食神'] >= 1)
            {
                return 9;
            }
            // 磨炼之年10 七杀为最高动神，且，如七杀透出天干未被合  透表示任意天干有七杀
            if ($dongshen['七杀'] == $max_dongshen
                &&
                (
                    ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $bazi[3])
                        && !$this->is_wuhe($bazi[1], $bazi[5])
                        && !$this->is_wuhe($bazi[1], $bazi[7])
                    )
                    &&
                    ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[3], $bazi[1])
                        && !$this->is_wuhe($bazi[3], $bazi[5])
                        && !$this->is_wuhe($bazi[3], $bazi[7])
                    )
                    &&
                    ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[7], $bazi[1])
                        && !$this->is_wuhe($bazi[7], $bazi[3])
                        && !$this->is_wuhe($bazi[7], $bazi[5])
                    )
                    &&
                    ($liugan_shishen == '七杀'
                        && !$this->is_wuhe($liu[0], $bazi[1])
                        && !$this->is_wuhe($liu[0], $bazi[3])
                        && !$this->is_wuhe($liu[0], $bazi[5])
                    )
                    &&
                    ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                        && !$this->is_wuhe($this->data['dayun_now'][0], $bazi[1])
                        && !$this->is_wuhe($this->data['dayun_now'][0], $bazi[3])
                        && !$this->is_wuhe($this->data['dayun_now'][0], $bazi[5])
                    )
                )
            )
            {
                return 10;
            }
            // 晦名之年11
            if ($this->option['recode']['type'] == 1 && $shangshen['正官'] >= 1)
            {
                return 11;
            }
            // 劳身之年12 禄受伤  检测年月日时运流年是否有日干的禄
            if (($this->is_lushen($rigan, $bazi[2])
                    && $shangshen[$this->param['shishen'][$y_zhi_benqi][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $bazi[4])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $bazi[6])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $bazi[8])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan]] >= 1)
                ||
                ($this->data['dayun_now'] != null && $this->is_lushen($rigan, $this->data['dayun_now'][1])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $liu[1])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan]] >= 1)
            )
            {
                return 12;
            }
        }
        /**
         * 日宫最高但未受伤
         * 桃花之年  女命，官杀动神；男命，财星动神
         * 名位之年  男命，官星动神且未受伤   官星 为正官
         * 创业之年  男命，七杀动神
         * 文书之年  印星动神且未受伤
         * 华秀之年  食神动神且未受伤，本命身旺
         * 权名之年  食神动神且未受伤，命运天干有七杀
         */
        if ($this->data['donggong'][2] == $max_donggong && $shanggong[2] < 1)
        {
            // 桃花之年 男
            if ($this->option['recode']['type'] == 1 && $is_cai_dongshen)
            {
                return 13;
            } // 桃花之年 女
            elseif ($this->option['recode']['type'] != 1 && $is_sha_dongshen)
            {
                return 14;
            }
            if ($this->option['recode']['type'] == 1)
            {
                // 名位之年
                if ($dongshen['正官'] > 0.5 && $shangshen['正官'] < 1)
                {
                    return 15;
                }
                // 创业之年
                if ($dongshen['七杀'] > 0.5)
                {
                    return 16;
                }
                // 文书之年
                if ($is_yin_dongshen && $shangshen['正印'] < 0.5 && $shangshen['偏印'] < 0.5)
                {
                    return 17;
                }
                if ($dongshen['食神'] > 0.5 && $shangshen['食神'] < 1)
                {
                    // 华秀之年
                    if ($this->data['shenwang'])
                    {
                        return 18;
                    } // 权名之年 命运天干有七杀
                    elseif ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        || $this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        || $this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        || ($this->data['dayun_now'] != null && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'))
                    {
                        return 19;
                    }
                }
            }
        }

        /**
         * 时宫最高且受伤
         * 子殇之年
         * 女命，食伤动神；男命，官杀动神
         */
        if ($this->data['donggong'][3] == $max_donggong && $shanggong[3] >= 1)
        {
            if ($this->option['recode']['type'] == 1 && $is_sha_dongshen)
            {
                return 20;
            } elseif ($this->option['recode']['type'] != 1 && $is_shi_dongshen)
            {
                return 21;
            }
        }

        /**
         * 时宫最高但未受伤（大于18岁）
         * 子女之年
         * 女命，食伤动神且未伤；男命，官杀动神且未伤
         */
        if ($this->data['donggong'][3] == $max_donggong && $shanggong[3] < 1
            && $this->option['advance']['year'] - $this->option['recode']['year'] > 18)
        {
            if (($this->option['recode']['type'] == 1 && $is_sha_dongshen && $shangshen['正官'] < 1 && $shangshen['七杀'] < 1)
                || ($this->option['recode']['type'] != 1 && $is_shi_dongshen && $shangshen['食神'] < 1 && $shangshen['伤官'] < 1))
            {
                return 22;
            }
        }

        /**
         * 比肩最高
         * 劳身之年  受伤
         * 不受伤  取次高的十神，转入后续判定
         */
        if ($dongshen['比肩'] == $max_dongshen)
        {
            if ($shangshen['比肩'] >= 1)
            {
                return 12;
            } else
            {
                // 次高的十神 赋值为最大
                $max_dongshen = array_shift($dongshenSort);
            }
        }

        /**
         * 劫财最高
         * 争财之年  年干或支本气为劫财，且劫财不与杀合
         * 命运劫财被流干合或克；流干劫财被命运七杀合
         *      男，权位之年
         *      女，夺情之年
         * 其它 取次高的十神，转入后续判定
         */
        if ($dongshen['劫财'] == $max_dongshen)
        {
            // 年干或支本气为劫财，且劫财不与杀合
            // 争财之年
            if (($this->param['shishen'][$bazi[1]][$rigan] == '劫财'
                    && ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $bazi[3]))
                    && ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $bazi[7]))
                    && ($liugan_shishen == '七杀'
                        && !$this->is_wuhe($bazi[1], $liu[0]))
                    && ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $this->data['dayun_now'][0]))
                )
                || (
                    $this->param['shishen'][$y_zhi_benqi][$rigan] == '劫财'
                    && ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $bazi[1]))
                    && ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $bazi[3]))
                    && ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $bazi[7]))
                    && ($liugan_shishen == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $liu[0]))
                    && ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $this->data['dayun_now'][0]))
                )
            )
            {
                return 23;
            }// 命运劫财被流干合或克；流干劫财被命运七杀合
            // 命运干有劫财，流干有七杀  且 七杀与劫财五合；或命运干有劫财，流干有正官
            elseif (
                ($this->param['shishen'][$bazi[1]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $bazi[1])))
                ||
                ($this->param['shishen'][$bazi[3]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $bazi[3])))
                ||
                ($this->param['shishen'][$bazi[7]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $bazi[7])))
                ||
                ($this->data['dayun_now'] != null
                    && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $this->data['dayun_now'][0])))
                ||
                (
                    ($this->param['shishen'][$bazi[1]][$rigan] == '劫财'
                        || $this->param['shishen'][$bazi[3]][$rigan] == '劫财'
                        || $this->param['shishen'][$bazi[7]][$rigan] == '劫财'
                        || ($this->data['dayun_now'] != null
                            && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '劫财')
                    )
                    && $liugan_shishen == '正官'
                )
                ||
                ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $bazi[1]))
                ||
                ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $bazi[3]))
                ||
                ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $bazi[7]))
                ||
                ($this->data['dayun_now'] != null
                    && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
            )
            {
                if ($this->option['recode']['type'] == 1)
                {
                    return 24;
                } else
                {
                    return 25;
                }
            } // 其它 取次高的十神，转入后续判定
            else
            {
                $max_dongshen = array_shift($dongshenSort);
            }
        }

        /**
         * 食神最高
         * 思虑之年  受伤
         * 华秀之年  不受伤
         */
        if ($dongshen['食神'] == $max_dongshen)
        {
            if ($shangshen['食神'] >= 1)
            {
                return 9;
            } else
            {
                return 18;
            }
        }

        /**
         * 伤官最高
         * 流干伤官被合，且无地支伤官冲穿官星
         *  名位之年    若流支为官或命运天干有官
         *  华秀之年    其它
         * 晦名之年  伤官与官所在柱冲穿；或官星受伤
         * 才艺之年 官星不受伤
         */
        if ($dongshen['伤官'] == $max_dongshen)
        {
            // 流干伤官 被合，且无地支伤官冲穿官星
            // 即：流年天干是伤官，被其它干五合，同时，流支不与命运地支中的官星冲穿
            if ($liugan_shishen == '伤官'
                &&
                (
                    $this->is_wuhe($liu[0], $bazi[1])
                    || $this->is_wuhe($liu[0], $bazi[3])
                    || $this->is_wuhe($liu[0], $bazi[7])
                    || ($this->data['dayun_now'] != null && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
                )
                &&
                (
                    ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[2])
                        && !$this->is_liuhai($liu[1], $bazi[2]))
                    ||
                    ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[4])
                        && !$this->is_liuhai($liu[1], $bazi[4]))
                    ||
                    ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[6])
                        && !$this->is_liuhai($liu[1], $bazi[6]))
                    ||
                    ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[8])
                        && !$this->is_liuhai($liu[1], $bazi[8]))
                    ||
                    ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $this->data['dayun_now'][1])
                        && !$this->is_liuhai($liu[1], $this->data['dayun_now'][1]))
                )
            )
            {
                // 名位之年
                if ($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] == '正官'
                    || $this->param['shishen'][$bazi[1]][$rigan] == '正官'
                    || $this->param['shishen'][$bazi[3]][$rigan] == '正官'
                    || $this->param['shishen'][$bazi[7]][$rigan] == '正官'
                    || ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '正官')
                )
                {
                    return 15;
                } // 华秀之年
                else
                {
                    return 18;
                }
            } // 晦名之年 伤官与官所在柱冲穿；或官星受伤
            // 即：伤官与官所在柱冲穿，是指，若某柱有正官存在，无论在干还是支，伤官与该柱地支冲穿
            elseif ($shangshen['正官'] >= 1
                ||
                (
                    (
                        ($liugan_shishen == '正官'
                            || $liuzhi_shishen == '正官')
                        &&
                        (
                            ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[2], $liu[1])
                                    || $this->is_liuhai($bazi[2], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $liu[1])
                                    || $this->is_liuhai($bazi[4], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $liu[1])
                                    || $this->is_liuhai($bazi[6], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $liu[1])
                                    || $this->is_liuhai($bazi[8], $liu[1])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $liu[1])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $liu[1])))
                        )
                    )
                    ||
                    (
                        $this->data['dayun_now'] != null
                        && ($this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '正官')
                        &&
                        (
                            ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[2], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[2], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[4], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[6], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[8], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($liu[1], $liu[1])
                                    || $this->is_liuhai($liu[1], $liu[1])))
                        )
                    )
                    ||
                    (
                        ($this->param['shishen'][$bazi[1]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '正官')
                        &&
                        (
                            ($liugan_shishen == '伤官'
                                && ($this->is_liuchong($bazi[2], $liu[1])
                                    || $this->is_liuhai($bazi[2], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $bazi[2])
                                    || $this->is_liuhai($bazi[4], $bazi[2])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $bazi[2])
                                    || $this->is_liuhai($bazi[6], $bazi[2])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $bazi[2])
                                    || $this->is_liuhai($bazi[8], $bazi[2])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $bazi[2])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $bazi[2])))
                        )
                    )
                    ||
                    (
                        ($this->param['shishen'][$bazi[3]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '正官')
                        &&
                        (
                            ($liugan_shishen == '伤官'
                                && ($this->is_liuchong($bazi[4], $liu[1])
                                    || $this->is_liuhai($bazi[4], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $bazi[2])
                                    || $this->is_liuhai($bazi[4], $bazi[2])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $bazi[4])
                                    || $this->is_liuhai($bazi[6], $bazi[4])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $bazi[4])
                                    || $this->is_liuhai($bazi[8], $bazi[4])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $bazi[4])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $bazi[4])))
                        )
                    )
                    ||
                    (
                        ($this->param['shishen'][$bazi[7]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '正官')
                        &&
                        (
                            ($liugan_shishen == '伤官'
                                && ($this->is_liuchong($bazi[8], $liu[1])
                                    || $this->is_liuhai($bazi[8], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $bazi[8])
                                    || $this->is_liuhai($bazi[4], $bazi[8])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $bazi[8])
                                    || $this->is_liuhai($bazi[6], $bazi[8])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $bazi[2])
                                    || $this->is_liuhai($bazi[8], $bazi[2])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $bazi[8])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $bazi[8])))
                        )
                    )
                )
            )
            {
                return 11;
            } // 才艺之年 官星不受伤
            elseif ($shangshen['正官'] < 1)
            {
                return 26;
            }
        }


        /**
         * 正财最高
         * 散财之年 27 受伤，或出现两个以上天干合正财 或流干流支一个是劫财一个是财星 20190117
         * 进财之年  不受伤，无分夺，印不受伤  (分夺是天干有多个比劫);或 印有受伤，但流支为正偏财、正官、食神且不与命运刑穿
         *  命运年天干及年支本气都没有偏财 28
         *  有偏财 29
         * 破印之年  印受伤
         */
        if ($dongshen['正财'] == $max_dongshen)
        {
            $gan_he_zhengcai_num = 0;
            if ($this->param['shishen'][$bazi[1]][$rigan] == '正财')
            {
                if ($this->is_wuhe($bazi[1], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[1], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[1], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[1], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($bazi[1], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($this->param['shishen'][$bazi[3]][$rigan] == '正财')
            {
                if ($this->is_wuhe($bazi[3], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[3], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[3], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[3], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($bazi[3], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($this->param['shishen'][$bazi[7]][$rigan] == '正财')
            {
                if ($this->is_wuhe($bazi[7], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[7], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[7], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[7], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($bazi[7], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($liugan_shishen == '正财')
            {
                if ($this->is_wuhe($liu[0], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($liu[0], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($liu[0], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($liu[0], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($this->data['dayun_now'] != null
                && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '正财')
            {
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }


            // 散财之年  受伤，或出现两个以上天干合正财
            //  或流干流支一个是劫财一个是财星 20190117
            if ($shangshen['正财'] >= 1 || $gan_he_zhengcai_num >= 2
                || ($liugan_shishen == '劫财' && in_array($liuzhi_shishen, ['正财', '偏财']))
                || ($liuzhi_shishen == '劫财' && in_array($liugan_shishen, ['正财', '偏财']))
            )
            {
                return 27;
            } // 进财之年
            elseif (
                ($shangshen['正财'] < 1 && $shangshen['正印'] < 1 && $shangshen['偏印'] < 1 && $gan_bijie_num == 0)
                ||
                (
                    ($shangshen['正印'] >= 1 || $shangshen['偏印'] >= 1)
                    && in_array($liuzhi_shishen, ['正财', '偏财', '正官', '食神'])
                    && !$this->is_xing($liu[1], $bazi[2]) && !$this->is_liuhai($liu[1], $bazi[2])
                    && !$this->is_xing($liu[1], $bazi[4]) && !$this->is_liuhai($liu[1], $bazi[4])
                    && !$this->is_xing($liu[1], $bazi[6]) && !$this->is_liuhai($liu[1], $bazi[6])
                    && !$this->is_xing($liu[1], $bazi[8]) && !$this->is_liuhai($liu[1], $bazi[8])
                    && ($this->data['dayun_now'] != null && !$this->is_xing($liu[1], $this->data['dayun_now'][1]) && !$this->is_liuhai($liu[1], $this->data['dayun_now'][1]))
                )
            )
            {
                // 命运年天干及年支本气都没有偏财
                if ($this->param['shishen'][$y_zhi_benqi][$rigan] != '偏财'
                    && $this->param['shishen'][$bazi[1]][$rigan] != '偏财')
                {
                    return 28;
                } // 有偏财
                else
                {
                    return 29;
                }
            } // 破印之年
            elseif ($shangshen['正印'] >= 1 && $shangshen['偏印'] >= 1)
            {
                return 30;
            }
        }

        /**
         * 偏财最高
         * 散财之年 27 受伤，年支比劫或命运天干比劫两座以上； 或流干流支一个是劫财一个是财星 20190117
         * 进财之年 不受伤，且印不受伤
         * 破印之年 30 印受伤
         */
        if ($dongshen['偏财'] == $max_dongshen)
        {
            // 散财之年
            //  或流干流支一个是劫财一个是财星 20190117
            if (
                (
                    $shangshen['偏财'] >= 1
                    && (in_array($this->param['shishen'][$y_zhi_benqi][$rigan], ['比肩', '劫财'])
                        || $gan_bijie_num >= 2)
                )
                ||
                (
                    ($liugan_shishen == '劫财' && in_array($liuzhi_shishen, ['正财', '偏财']))
                    || ($liuzhi_shishen == '劫财' && in_array($liugan_shishen, ['正财', '偏财']))
                )
            )
            {
                return 27;
            } // 进财之年
            elseif ($shangshen['偏财'] < 1 && $shangshen['正印'] < 1 && $shangshen['偏印'] < 1)
            {
                return 29;
            } // 破印之年
            elseif ($shangshen['正印'] >= 1 && $shangshen['偏印'] >= 1)
            {
                return 30;
            }
        }

        /**
         * 正官最高
         * 晦名之年  受伤
         * 名位之年 不受伤
         */
        if ($dongshen['正官'] == $max_dongshen)
        {
            if ($shangshen['正官'] >= 1)
            {
                return 11;
            } else
            {
                return 15;
            }
        }

        /**
         * 七杀最高
         * 权名之年  命运七杀被流干合，或流干七杀被岁运合
         * 磨砺之年  本命官杀五行比重高于比劫+印星，或流支与本命日支冲穿刑，或流支与日干禄冲穿刑
         * 创业之年  其它
         */
        if ($dongshen['七杀'] == $max_dongshen)
        {
            // 权名之年  命运七杀被流干合，或流干七杀被岁运合
            if (
                ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $bazi[1]))
                ||
                ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $bazi[3]))
                ||
                ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $bazi[7]))
                ||
                ($this->data['dayun_now'] != null
                    && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
                ||
                (
                    $liugan_shishen == '七杀'
                    &&
                    (
                        $this->is_wuhe($bazi[1], $liu[0])
                        || ($this->data['dayun_now'] != null
                            && $this->is_wuhe($bazi[1], $this->data['dayun_now'][0]))
                    )
                )
            )
            {
                return 19;
            } // 磨砺之年  本命官杀五行比重高于比劫+印星，或流支与本命日支冲穿刑，或流支与日干禄冲穿刑
            elseif (
                (
                    $this->data['shishen_wuxing']['官杀'] > $this->data['shishen_wuxing']['比劫']
                    + $this->data['shishen_wuxing']['印']
                )
                || $this->is_liuchong($liu[1], $bazi[6])
                || $this->is_xing($liu[1], $bazi[6])
                || $this->is_liuhai($liu[1], $bazi[6])
                || ($this->is_lushen($rigan, $bazi[2])
                    && ($this->is_xing($liu[1], $bazi[2])
                        || $this->is_liuchong($liu[1], $bazi[2])
                        || $this->is_liuhai($liu[1], $bazi[2])))
                || ($this->is_lushen($rigan, $bazi[2])
                    && ($this->is_xing($liu[1], $bazi[2])
                        || $this->is_liuchong($liu[1], $bazi[2])
                        || $this->is_liuhai($liu[1], $bazi[2])))
                || ($this->is_lushen($rigan, $bazi[4])
                    && ($this->is_xing($liu[1], $bazi[4])
                        || $this->is_liuchong($liu[1], $bazi[4])
                        || $this->is_liuhai($liu[1], $bazi[4])))
                || ($this->is_lushen($rigan, $bazi[6])
                    && ($this->is_xing($liu[1], $bazi[6])
                        || $this->is_liuchong($liu[1], $bazi[6])
                        || $this->is_liuhai($liu[1], $bazi[6])))
                || ($this->is_lushen($rigan, $bazi[8])
                    && ($this->is_xing($liu[1], $bazi[8])
                        || $this->is_liuchong($liu[1], $bazi[8])
                        || $this->is_liuhai($liu[1], $bazi[8])))
                || ($this->data['dayun_now'] != null
                    && $this->is_lushen($rigan, $this->data['dayun_now'][1])
                    && ($this->is_xing($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuchong($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuhai($liu[1], $this->data['dayun_now'][1])))
            )
            {
                // 磨砺之年词条 为 磨炼之年
                return 10;
            } // 创业之年
            else
            {
                return 16;
            }
        }

        /**
         * 正印最高
         * 破印之年 受伤
         * 不受伤
         *  迁动之年  流年冲命运
         *  安乐之年  不冲
         */
        if ($dongshen['正印'] == $max_dongshen)
        {
            // 破印之年
            if ($shangshen['正印'] >= 1)
            {
                return 30;
            } else
            {
                // 迁动之年  流年冲命运
                if ($this->is_liuchong($liu[1], $bazi[2])
                    || $this->is_liuchong($liu[1], $bazi[4])
                    || $this->is_liuchong($liu[1], $bazi[6])
                    || $this->is_liuchong($liu[1], $bazi[7])
                    || ($this->data['dayun_now'] != null && $this->is_liuchong($liu[1], $this->data['dayun_now'][1]))
                )
                {
                    return 31;
                } // 安乐之年
                else
                {
                    return 32;
                }
            }
        }

        /**
         * 偏印最高
         * 夺食之年  食神受伤
         * 食神不受伤
         *  迁动之年  流年冲命运
         *  不冲  取次高的十神，重新判定
         */
        if ($dongshen['偏印'] == $max_dongshen)
        {
            // 夺食之年
            if ($shangshen['食神'] >= 1)
            {
                return 33;
            } else
            {
                // 迁动之年  流年冲命运
                if ($this->is_liuchong($liu[1], $bazi[2])
                    || $this->is_liuchong($liu[1], $bazi[4])
                    || $this->is_liuchong($liu[1], $bazi[6])
                    || $this->is_liuchong($liu[1], $bazi[7])
                    || ($this->data['dayun_now'] != null && $this->is_liuchong($liu[1], $this->data['dayun_now'][1]))
                )
                {
                    return 31;
                } // 不冲  取次高的十神，重新判定
                else
                {
                    $max_dongshen = array_shift($dongshenSort);
                    return self::getTopic($dongshenSort, $max_dongshen);
                }
            }
        }
        return -1;
    }

    /**
     * 年运概括添加
     * 变量
     * 20XX年，调取年份
     * Y 调取木星所在宫位，每月取一次数据，取所在宫位次数多的
     *      1命宫、2财务宫、3外出宫、4父母宫、5恋爱宫、6劳务宫、7婚姻宫、8偏财宫、9旅行宫、10事业宫、11福德宫、12灵性宫
     * Z 调取土星所在宫位，每月取一次数据，取所在宫位次数多的
     * W 木星所在宫位Y
     *  1宫 身体健康、个人成长
     *  2 财富、物质享受
     *  3 学习、出行
     *  4 家庭、房产
     *  5 情感、娱乐、创作
     *  6 工作
     *  7 婚恋、合作、交际
     *  8 理财、商业
     *  9 旅游、教育
     *  10 事业
     *  11 交际、事业
     *  12 精神成长
     * T
     *  T=1宫
     *  2
     *  3
     *  4
     * S 当年的属相
     * R
     *  当流支=本命年支           是你的本命年，但本命年也有好有坏，不必过于担心。
     *  当流支与本命年支相冲       你今年有一点犯太岁，但一般来说并无大碍。
     *  当流支与本命年支相穿       你今年有轻微的犯太岁，但一般没什么大问题。
     *  当流支与本命年支相刑       你今年有轻微的犯太岁，但一般没什么大问题。
     *  其它                    你与太岁并不冲犯，民俗认为是平安喜乐的好年份。
     *
     * Y不等于Z时输出词条
     *      20XX年，木星会在你的Y宫、土星会在你的Z宫停留较长时间，你会在W方面得到更多的机会或好运气，并在T方面落实一些事情，学会去面对和承担，认真对待，你就能借此解决一些存留已久的问题。传统上，这一年是S年，R
     * Y等于Z时输出词条
     *      20XX年，木星和土星都会在你的Y宫停留很久，你会在W方面得到更多的机会或好运气，并能落实一些事情，学会去面对和承担，认真对待，你就能借此解决一些存留已久的问题。传统上，这一年是S年，R
     */
    public function getTopicExtend()
    {
//        $liu = $this->data['liunian_now'];
//        $bazi = $this->data['bazi'];
//        $rigan = $bazi[5];

    }

    /**
     * 获取年运重点
     * @return array
     */
    public function getPoint()
    {
        $result = [];

        $advanceInfo = [
            'year' => $this->option['advance']['year'],
            'month' => 3,
            'day' => 1,
            'hour' => 12,
            'minute' => 0,
            'timezone' => 8,
            'is_summer' => 0,
            'longitude' => $this->option['recode']['longitude'],// 使用本命经纬度
            'latitude' => $this->option['recode']['latitude'],// 使用本命经纬度
        ];

        $Astrolog = Astrolog::getInstance();

        $Astrolog->setRecode1($this->option['recode'])
            ->setAdvance($advanceInfo)
            ->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(false)
            ->setUserSetting(config('astroset.setting1'))
            ->setGetDatas(['thirdprogressed']);

        $Astrolog->getAstroDatas();
        // 3月1号三限
        $source1 = $Astrolog->getAstroDatas()->getDatas('thirdprogressed');

        // 10月1号三限
        $advanceInfo['month'] = 10;
        $source2 = $Astrolog->setAdvance($advanceInfo)->getAstroDatas()->getDatas('thirdprogressed');
        // 7月1号三限
        $advanceInfo['month'] = 7;
        $source3 = $Astrolog->setAdvance($advanceInfo)->getAstroDatas()->getDatas('thirdprogressed');

        $liu = $this->data['liunian_now'];
        $bazi = $this->data['bazi'];
        $rigan = $bazi[5];
        $donggong = $this->data['donggong'];
        $dongshen = $dongshenSort = $this->data['dongshen'];
        $shanggong = $this->data['shanggong'];
        $shangshen = $this->data['shangshen'];
        $shishen_wuxing = $this->data['shishen_wuxing'];
        $liu_benqi = $this->param['canggan'][$liu[1]][0];
        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];
        $liuzhi_shishen = $this->param['shishen'][$liu_benqi][$rigan];
        $dayun = $this->data['dayun_now'] != null ? $this->data['dayun_now'] : null;
        $dayun_benqi = $dayun != null ? $this->param['canggan'][$dayun[1]][0] : null;
        /**
         * 情感纠葛
         * 三限是否有金冥刑冲相位（分别检测3月1号和10月1号，其一满足，下同）
         */
        if ((isset($source1['planets'][3]['phase']['3-9']) && in_array($source1['planets'][3]['phase']['3-9']['phase_e'], [90, 180]))
            || (isset($source2['planets'][3]['phase']['3-9']) && in_array($source2['planets'][3]['phase']['3-9']['phase_e'], [90, 180])))
        {
            $result[] = 0;
        }

        /**
         * 桃花
         * 三限是否有金木/金火/日金相位，且其一星在5/7宫，金星不与土星海王刑冲
         */
        $is_1p5_inhouse_57 = in_array($source1['planets'][3]['in_house_id'], [5, 7]);
        $is_2p5_inhouse_57 = in_array($source2['planets'][3]['in_house_id'], [5, 7]);
        if (
            (
                (!isset($source1['planets'][3]['phase']['3-6']) || !in_array($source1['planets'][3]['phase']['3-6']['phase_e'], [90, 180]))
                && (!isset($source1['planets'][3]['phase']['3-8']) || !in_array($source1['planets'][3]['phase']['3-8']['phase_e'], [90, 180]))
                &&
                (
                    (isset($source1['planets'][3]['phase']['3-0'])
                        && ($is_1p5_inhouse_57 || in_array($source1['planets'][0]['in_house_id'], [5, 7])))
                    || (isset($source1['planets'][3]['phase']['3-4'])
                        && ($is_1p5_inhouse_57 || in_array($source1['planets'][4]['in_house_id'], [5, 7])))
                    || (isset($source1['planets'][3]['phase']['3-5'])
                        && ($is_1p5_inhouse_57 || in_array($source1['planets'][5]['in_house_id'], [5, 7])))
                )
            )
            ||
            (
                (!isset($source2['planets'][3]['phase']['3-6']) || !in_array($source2['planets'][3]['phase']['3-6']['phase_e'], [90, 180]))
                && (!isset($source2['planets'][3]['phase']['3-8']) || !in_array($source2['planets'][3]['phase']['3-8']['phase_e'], [90, 180]))
                &&
                (
                    (isset($source2['planets'][3]['phase']['3-0'])
                        && ($is_2p5_inhouse_57 || in_array($source2['planets'][0]['in_house_id'], [5, 7])))
                    || (isset($source2['planets'][3]['phase']['3-4'])
                        && ($is_2p5_inhouse_57 || in_array($source2['planets'][4]['in_house_id'], [5, 7])))
                    || (isset($source2['planets'][3]['phase']['3-5'])
                        && ($is_2p5_inhouse_57 || in_array($source2['planets'][5]['in_house_id'], [5, 7])))
                )
            )
        )
        {
            $result[] = 1;
        }
        /**
         * 机遇
         *  该年3月1号，10月1号，其中一日的三限有日木相位（涉及三限的都检测这两天）
         */
        $is_tp_phase05_31 = isset($source1['planets'][0]['phase']['0-5']);
        $is_tp_phase05_101 = isset($source2['planets'][0]['phase']['0-5']);

        $replace_word = [
            1 => [
                1 => 35,
                2 => 36,
                3 => 37,
                4 => 38,
                5 => 39,
                6 => 40,
                7 => 41,
                8 => 42,
                9 => 43,
                10 => 44,
                11 => 45,
                12 => 46,
            ],
            2 => [
                1 => 47,
                2 => 48,
                3 => 49,
                4 => 50,
                5 => 51,
                6 => 52,
                7 => 53,
                8 => 54,
                9 => 55,
                10 => 56,
                11 => 57,
                12 => 58,
            ],
            3 => [
                1 => 59,
                2 => 60,
                3 => 61,
                4 => 62,
                5 => 63,
                6 => 64,
                7 => 65,
                8 => 66,
                9 => 67,
                10 => 68,
                11 => 69,
                12 => 70,
            ],
        ];
        // 只有3月份有
        if ($is_tp_phase05_31 && !$is_tp_phase05_101)
        {
            $p5_house = $source1['planets'][5]['in_house_id'];
            $result[] = $replace_word[1][$p5_house];
        }// 只有十月有
        elseif (!$is_tp_phase05_31 && $is_tp_phase05_101)
        {
            $p5_house = $source2['planets'][5]['in_house_id'];
            $result[] = $replace_word[2][$p5_house];
        }// 两天都有
        else
        {
            $p5_house = $source1['planets'][5]['in_house_id'];
            $result[] = $replace_word[3][$p5_house];
        }

        /**
         * 贵人
         *  三限太阳与金木同时成相，或八字流年为以下情形：天干比肩+地支正官，天干比肩+地支贵人，天干正官+地支日禄，天干正官+地支财星，天干财星+地支正官
         * 20181228
         * 1。三限太阳与金木同时成相，或，三限木星在7宫与太阳或金星合拱六分
         * 2。八字流年为以下情形：天干比肩+地支正官，天干比肩+地支贵人，天干正官+地支日禄，天干正官+地支财星，天干财星+地支正官
         *  正官受伤大于0小于1
         *  正官未受伤
         */
        // 三限太阳与金木同时成相，或，三限木星在7宫与太阳或金星合拱六分
        if (
            (isset($source1['planets'][0]['phase']['0-3'])
                && (isset($source1['planets'][0]['phase']['0-5'])
                    || isset($source2['planets'][0]['phase']['0-5'])))
            || (isset($source1['planets'][0]['phase']['0-5'])
                && (isset($source1['planets'][0]['phase']['0-3'])
                    || isset($source2['planets'][0]['phase']['0-3'])))
            ||
            ($source1['planets'][5]['in_house_id'] == 7
                && checkPhase([5], [0, 3], [0, 60, 120], $source1['planets']))
            ||
            ($source2['planets'][5]['in_house_id'] == 7
                && checkPhase([5], [0, 3], [0, 60, 120], $source2['planets']))
        )
        {
            $result[] = 71;
        }// 八字流年为以下情形：天干比肩+地支正官，天干比肩+地支贵人，天干正官+地支日禄，天干正官+地支财星，天干财星+地支正官
        elseif (($this->param['shishen'][$liu[0]][$rigan] == '比肩'
                && ($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] == '正官')
                || $this->is_tianyiguiren($rigan, $liu[1]))
            ||
            ($this->param['shishen'][$liu[0]][$rigan] == '正官'
                && (
                    in_array($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan], ['正财', '偏财'])
                    || $this->is_lushen($rigan, $liu[1])))
            ||
            (in_array($this->param['shishen'][$liu[0]][$rigan], ['正财', '偏财'])
                && $this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] == '正官'))
        {
            // 正官受伤大于0小于1
            if ($shangshen['正官'] > 0 && $shangshen['正官'] < 1)
            {
                $result[] = 72;
            } // 正官未受伤
            elseif ($shangshen['正官'] <= 0)
            {
                $result[] = 73;
            }
        }

        /**
         * 旅行
         * 三限水木成非刑相，或日木成相且其一在3/9宫
         */
        if (
            (
                isset($source1['planets'][2]['phase']['2-5'])
                && $source1['planets'][2]['phase']['2-5']['phase_e'] != 90
                && isset($source1['planets'][0]['phase']['0-5'])
                && (in_array($source1['planets'][0]['in_house_id'], [3, 9])
                    || in_array($source1['planets'][5]['in_house_id'], [3, 9]))
            )
            ||
            (
                isset($source2['planets'][2]['phase']['2-5'])
                && $source2['planets'][2]['phase']['2-5']['phase_e'] != 90
                && isset($source2['planets'][0]['phase']['0-5'])
                && (in_array($source2['planets'][0]['in_house_id'], [3, 9])
                    || in_array($source2['planets'][5]['in_house_id'], [3, 9]))
            )
        )
        {
            $result[] = 30;
        }

        /**
         * 迁移变动
         * 八字印星动且高于0.5，同时三限有3/9宫的对冲并有木星或天王参与
         */
        $is_tp_57_house39_180 = false;
        if (in_array($source1['planets'][5]['in_house_id'], [3, 9])
            && !empty($source1['planets'][5]['phase']))
        {
            foreach ($source1['planets'][5]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($is_tp_57_house39_180 === false &&
            in_array($source1['planets'][7]['in_house_id'], [3, 9])
            && !empty($source1['planets'][7]['phase']))
        {
            foreach ($source1['planets'][7]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($is_tp_57_house39_180 === false &&
            in_array($source2['planets'][5]['in_house_id'], [3, 9])
            && !empty($source2['planets'][5]['phase']))
        {
            foreach ($source2['planets'][5]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($is_tp_57_house39_180 === false &&
            in_array($source2['planets'][7]['in_house_id'], [3, 9])
            && !empty($source2['planets'][7]['phase']))
        {
            foreach ($source2['planets'][7]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($dongshen['正印'] + $dongshen['偏印'] > 0 && $is_tp_57_house39_180)
        {
            $result[] = 31;
        }


        /**
         * 福缘 33
         * 三限木星在1宫或10宫，且火土海冥不与太阳成相不合轴不在1宫10宫
         * 三限金木成合拱六分相，且金星不与土星刑冲
         *
         * 1.（检测该年7月1号三限）三限木星在1宫或10宫，且火土海冥不与太阳成相不合轴不在1宫10宫
         * 2.（检测该年7月1号三限）限金木成合拱六分相，且金星、太阳不与土星刑冲且2宫无土星
         */
        // （检测该年7月1号三限）三限木星在1宫或10宫，且火土海冥不与太阳成相不合轴不在1宫10宫
        if (!checkSignHouse([5], [1, 10], $source3['planets'])
            && !checkPhase([4, 6, 8, 9], [0], [], $source3['planets'])
            && checkSignHouse([4, 6, 8, 9], [1, 10], $source3['planets'])
            && checkPhase([4, 6, 8, 9], [ASC, MC], [0, 180], $source3['planets']))
        {
            $result[] = 74;
        } // （检测该年7月1号三限）限金木成合拱六分相，且金星、太阳不与土星刑冲且2宫无土星
        elseif (checkPhase([3], [5], [0, 60, 120], $source3['planets'])
            && !checkPhase([0, 3], [6], [90, 180], $source3['planets'])
            && $source3['planets'][6]['in_house_id'] != 2)
        {
            $result[] = 75;
        }


        /**
         * 学识 34
         * 三限木星在3宫，或水木成非刑相，同时八字流年干支（本气）有正偏印或食神伤官之一
         *
         * （检测该年7月1号三限）三限木星在3宫，或水木成非刑相，且水海不成刑冲合，同时八字流年干支（本气）有正偏印或食神伤官之一
         */
        if (
            ($source3['planets'][5]['in_house_id'] == 3
                ||
                (checkPhase([2], [5], [0, 60, 120, 180], $source3['planets'])
                    && !checkPhase([2], [8], [0, 90, 180], $source3['planets'])))
            ||
            (
                in_array($liugan_shishen, ['正印', '偏印', '食神', '伤官'])
                || in_array($liuzhi_shishen, ['正印', '偏印', '食神', '伤官'])
            )
        )
        {
            $result[] = 34;
        }

        /**
         * 检测日宫是否动
         */
        if ($donggong[2] > 0)
        {
            // 夫妻星动
            $is_fuqixing_dong = false;
            // 检测夫妻星 男命 财星  女命 官杀
            $fuqixing = [];
            if ($this->option['recode']['type'] == 1)
            {
                if ($dongshen['正财'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '正财';
                }
                if ($dongshen['偏财'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '偏财';
                }
            } else
            {
                if ($dongshen['正官'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '正官';
                }
                if ($dongshen['七杀'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '七杀';
                }
            }
            // 日宫受伤且夫妻星（男财女官杀）动
            if ($shanggong[2] >= 1 && $is_fuqixing_dong)
            {
                //日支是辰戌丑未且大运流年对其无穿，或，日支不受大运流年刑穿
                if ((
                        in_array($bazi[6], ['辰', '戌', '丑', '未'])
                        && !$this->is_liuhai($liu[1], $bazi[6])
                        && ($dayun != null && !$this->is_liuhai($liu[1], $dayun[1])))
                    || (!$this->is_liuhai($liu[1], $bazi[6]) && !$this->is_xing($liu[1], $bazi[6])
                        && ($dayun != null
                            && !$this->is_liuhai($dayun[1], $bazi[6])
                            && !$this->is_xing($dayun[1], $bazi[6]))))
                {
                    $is_low = false;
                    foreach ($fuqixing as $fqx)
                    {
                        if ($shangshen[$fqx] < 0.7)
                        {
                            $is_low = true;
                        }
                    }
                    // 婚恋1
                    if ($is_low === true)
                    {
                        $result[] = 2;
                    }// 情感问题
                    else
                    {
                        $result[] = 3;
                    }
                } else
                {
                    // 情感伤害 女，本命官杀五行超过40%，流年干支有七杀，且流支有刑冲穿
                    if ($this->option['recode']['type'] != 1 && $shishen_wuxing['官杀'] >= 40
                        && ($liugan_shishen == '七杀' || $liuzhi_shishen == '七杀')
                        && (
                            $this->is_xing($liu[1], $bazi[2])
                            || $this->is_liuchong($liu[1], $bazi[2])
                            || $this->is_liuhai($liu[1], $bazi[2])
                            || $this->is_xing($liu[1], $bazi[4])
                            || $this->is_liuchong($liu[1], $bazi[4])
                            || $this->is_liuhai($liu[1], $bazi[4])
                            || $this->is_xing($liu[1], $bazi[6])
                            || $this->is_liuchong($liu[1], $bazi[6])
                            || $this->is_liuhai($liu[1], $bazi[6])
                            || $this->is_xing($liu[1], $bazi[8])
                            || $this->is_liuchong($liu[1], $bazi[8])
                            || $this->is_liuhai($liu[1], $bazi[8])
                            || (
                                $dayun != null
                                && (
                                    $this->is_xing($liu[1], $dayun[1])
                                    || $this->is_liuchong($liu[1], $dayun[1])
                                    || $this->is_liuhai($liu[1], $dayun[1])
                                )
                            )
                        )
                    )
                    {
                        $result[] = 4;
                    } // 过路桃花 本命夫妻星五行为0%，大运也无夫妻星（包括藏干）
                    elseif (
                        ($this->option['recode']['type'] == 1 && $shishen_wuxing['财'] == 0
                            && (
                                $dayun == null
                                || (
                                    !in_array($this->param['shishen'][$dayun[0]][$rigan], ['正财', '偏财'])
                                    && !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正财', '偏财'])
                                )
                            )
                        )
                        ||
                        ($this->option['recode']['type'] == 1 && $shishen_wuxing['官杀'] == 0
                            && (
                                $dayun == null
                                || (
                                    !in_array($this->param['shishen'][$dayun[0]][$rigan], ['正官', '七杀'])
                                    && !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正官', '七杀'])
                                )
                            )
                        )
                    )
                    {
                        $result[] = 5;
                    } // 过路桃花 女，本命食伤超过50%且大运地支不是官杀，或男，本命比劫超过50%且大运地支不是财星
                    elseif (
                        ($this->option['recode']['type'] != 1 && $shishen_wuxing['食伤'] >= 50
                            && ($dayun == null || !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正官', '七杀'])))
                        ||
                        ($this->option['recode']['type'] == 1 && $shishen_wuxing['比劫'] >= 50
                            && ($dayun == null || !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正财', '偏财'])))
                    )
                    {
                        $result[] = 5;
                    } // 情感问题 其它
                    else
                    {
                        $result[] = 3;
                    }
                }
            }// 日宫不受伤且夫妻星动
            elseif ($shanggong[2] < 1 && $is_fuqixing_dong)
            {
                // 婚恋2 印星动
                if ($dongshen['正印'] > 0 || $dongshen['偏印'] > 0)
                {
                    $result[] = 6;
                }// 印星不动
                else
                {
                    $result[] = 1;
                }
            }
        }

        /**
         * 检测流年是否有官杀
         */
        if (in_array($liugan_shishen, ['正官', '七杀']) || in_array($liuzhi_shishen, ['正官', '七杀']))
        {
            // 正官（官杀都有按流干算）
            if (($liuzhi_shishen == '正官' && $liugan_shishen == '七杀') || ($liuzhi_shishen == '七杀' && $liugan_shishen == '正官')
                || (in_array($liugan_shishen, ['正官', '七杀']) && !in_array($liuzhi_shishen, ['正官', '七杀'])))
            {
                $shishen_temp1 = $liugan_shishen;
                $shishen_temp2 = $liuzhi_shishen;
                $main = $liu[0];
            } else
            {
                $shishen_temp1 = $liuzhi_shishen;
                $shishen_temp2 = $liugan_shishen;
                $main = $liu_benqi;
            }
            if ($shishen_temp1 == '正官')
            {
                // 流年另一干支是不是伤官
                if ($shishen_temp2 == '伤官')
                {
                    // 升职 流干/支 伤官被合
                    if ($this->is_wuhe($main, $bazi[1])
                        || $this->is_wuhe($main, $bazi[3])
                        || $this->is_wuhe($main, $bazi[5])
                        || $this->is_wuhe($main, $bazi[7])
                        || ($dayun != null && $this->is_wuhe($main, $dayun[0]))
                    )
                    {
                        $result[] = 7;
                    }// 事业挫折
                    else
                    {
                        $result[] = 8;
                    }
                } else
                {
                    // 流年另一干支是否财或比肩
                    if (in_array($shishen_temp2, ['正财', '偏财', '比肩']))
                    {
                        // 20190104 增加一步判断：流年是否与命运某柱双冲且该柱干支之一是伤官，是的话不是升职，而是事业调整
                        if (
                            (
                                $this->is_shuangchong($liu, [[$bazi[1], $bazi[2]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[1]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->is_shuangchong($liu, [[$bazi[3], $bazi[4]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[3]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->is_shuangchong($liu, [[$bazi[5], $bazi[6]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[5]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->is_shuangchong($liu, [[$bazi[7], $bazi[8]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[7]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->data['dayun_now'] != null
                                && $this->is_shuangchong($liu, [$this->data['dayun_now']])
                                &&
                                (
                                    $this->param['shishen'][$this->data['dayun_now'][0]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan]
                                )
                            )
                        )
                        {
                            $result[] = 9;
                        } // 否则  升职
                        else
                        {
                            $result[] = 7;
                        }
                    } else
                    {
                        // 正官是否受伤
                        // 事业挫折
                        if ($shangshen['正官'] > 0.6)
                        {
                            $result[] = 8;
                        } // 事业调整
                        elseif ($shangshen['正官'] > 0)
                        {
                            $result[] = 9;
                        } // 升职
                        elseif ($shangshen['正官'] == 0)
                        {
                            $result[] = 7;
                        }
                    }
                }
            }//  七杀（官杀都有按流干算）
            else
            {
                // 本命比劫+印星+食伤比例超过50%
                if ($shishen_wuxing['比劫'] + $shishen_wuxing['印'] + $shishen_wuxing['食伤'] >= 50)
                {
                    // 奔走 流支或运支七杀与日干禄冲
                    if (
                        ($liuzhi_shishen == '七杀'
                            &&
                            (
                                ($this->is_liuchong($liu[1], $bazi[2]) && $this->is_lushen($rigan, $bazi[2]))
                                || ($this->is_liuchong($liu[1], $bazi[4]) && $this->is_lushen($rigan, $bazi[4]))
                                || ($this->is_liuchong($liu[1], $bazi[6]) && $this->is_lushen($rigan, $bazi[6]))
                                || ($this->is_liuchong($liu[1], $bazi[8]) && $this->is_lushen($rigan, $bazi[8]))
                            )
                        )
                        ||
                        ($dayun != null && $this->param['shishen'][$dayun_benqi][$rigan] == '七杀'
                            &&
                            (
                                ($this->is_liuchong($dayun[1], $bazi[2]) && $this->is_lushen($rigan, $bazi[2]))
                                || ($this->is_liuchong($dayun[1], $bazi[4]) && $this->is_lushen($rigan, $bazi[4]))
                                || ($this->is_liuchong($dayun[1], $bazi[6]) && $this->is_lushen($rigan, $bazi[6]))
                                || ($this->is_liuchong($dayun[1], $bazi[8]) && $this->is_lushen($rigan, $bazi[8]))
                            )
                        )
                    )
                    {
                        $result[] = 10;
                    }// 创业
                    else
                    {
                        $result[] = 11;
                    }
                } // 创业 流干是七杀命运天干有食神 ，或 流干七杀被命运天干合
                elseif ($liugan_shishen == '七杀'
                    &&
                    (
                        (
                            $this->param['shishen'][$bazi[1]][$rigan] == '食神'
                            || $this->param['shishen'][$bazi[3]][$rigan] == '食神'
                            || $this->param['shishen'][$bazi[7]][$rigan] == '食神'
                            || ($dayun != null
                                && $this->param['shishen'][$dayun[0]][$rigan] == '食神')
                        )
                        ||
                        (
                            $this->is_wuhe($liu[0], $bazi[1])
                            || $this->is_wuhe($liu[0], $bazi[3])
                            || $this->is_wuhe($liu[0], $bazi[5])
                            || $this->is_wuhe($liu[0], $bazi[6])
                            || ($dayun != null && $this->is_wuhe($liu[0], $dayun[0]))
                        )
                    )
                )
                {
                    $result[] = 11;
                } // 创业 命运天干有七杀，流干食神或流干合七杀
                elseif (
                    (
                        $this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($bazi[1], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                    ||
                    (
                        $this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($bazi[3], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                    ||
                    (
                        $this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($bazi[7], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                    ||
                    (
                        $dayun != null
                        && $this->param['shishen'][$dayun[0]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($dayun[0], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                )
                {
                    $result[] = 11;
                }
            }
        } // 检测官杀是否动
        else
        {
            // 官动
            if ($dongshen['正官'] > 0)
            {
                // 事业挫折
                if ($shangshen['正官'] > 0.6)
                {
                    $result[] = 8;
                } // 事业调整
                elseif ($shangshen['正官'] > 0)
                {
                    $result[] = 9;
                } // 升职
                elseif ($shangshen['正官'] == 0)
                {
                    $result[] = 7;
                }
            }// 杀动
            elseif ($dongshen['七杀'] > 0)
            {
                // 本命天干或日支有食神或正印，或官杀旺度低于30%
                // 创业
                if (
                    in_array($this->param['shishen'][$bazi[1]][$rigan], ['食神', '正印'])
                    || in_array($this->param['shishen'][$bazi[3]][$rigan], ['食神', '正印'])
                    || in_array($this->param['shishen'][$bazi[7]][$rigan], ['食神', '正印'])
                    || in_array($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan], ['食神', '正印'])
                    || $shishen_wuxing['官杀'] < 30
                )
                {
                    $result[] = 11;
                } // 意外
                else
                {
                    $result[] = 12;
                }
            }
        }

        /**
         * 检测流年是否有财星，或是否财星动
         */
        if (in_array($liugan_shishen, ['正财', '偏财'])
            || in_array($liuzhi_shishen, ['正财', '偏财'])
            || $dongshen['正财'] > 0
            || $dongshen['偏财'] > 0)
        {
            // 正财（正偏都有按偏财算）
            if (($liuzhi_shishen == '正财' && $liugan_shishen == '偏财') || ($liuzhi_shishen == '偏财' && $liugan_shishen == '正财')
                || (in_array($liugan_shishen, ['正财', '偏财']) && !in_array($liuzhi_shishen, ['正财', '偏财'])))
            {
                $shishen_temp1 = $liugan_shishen;
//                $shishen_temp2 = $liuzhi_shishen;
//                $main = $liu[0];
            } else
            {
                $shishen_temp1 = $liuzhi_shishen;
//                $shishen_temp2 = $liugan_shishen;
//                $main = $liu_benqi;
            }

            if ($shishen_temp1 == '正财')
            {
                // 财来财去 流干为财，运干比劫
                if (in_array($liugan_shishen, ['正财', '偏财'])
                    && ($dayun != null
                        && in_array($this->param['shishen'][$dayun[0]][$rigan], ['比肩', '劫财'])))
                {
                    $result[] = 13;
                } //
                else
                {
                    // 财是否受伤
                    // 耗财
                    if ($shangshen['正财'] + $shangshen['偏财'] > 0.6)
                    {
                        $result[] = 14;
                    } // 财来财去
                    elseif ($shangshen['正财'] + $shangshen['偏财'] > 0)
                    {
                        $result[] = 13;
                    } // 进财
                    elseif ($shangshen['正财'] + $shangshen['偏财'] == 0)
                    {
                        $result[] = 15;
                    }
                }
            }// 偏财
            else
            {
                // 财来财去 流干为财，运干比劫
                if (in_array($liugan_shishen, ['正财', '偏财'])
                    && ($dayun != null
                        && in_array($this->param['shishen'][$dayun[0]][$rigan], ['比肩', '劫财'])))
                {
                    $result[] = 16;
                } //
                else
                {
                    // 财是否受伤
                    // 耗财
                    if ($shangshen['正财'] + $shangshen['偏财'] > 0.6)
                    {
                        $result[] = 17;
                    } // 财来财去
                    elseif ($shangshen['正财'] + $shangshen['偏财'] > 0)
                    {
                        $result[] = 16;
                    } // 进财
                    elseif ($shangshen['正财'] + $shangshen['偏财'] == 0)
                    {
                        $result[] = 18;
                    }
                }
            }
        }

        /**
         * 印星主神或印动指数高于0.4
         */
        if (in_array('正印', $this->data['liunianzhushen'])
            || in_array('偏印', $this->data['liunianzhushen'])
            || $dongshen['正印'] + $dongshen['偏印'] > 0.4
        )
        {
            // 正印受伤高于0.5
            if ($shangshen['正印'] > 0)
            {
                $result[] = 19;
            } elseif ($shangshen['正印'] < 0.5
                && !in_array($liugan_shishen, ['正财', '偏财'])
                && !in_array($liuzhi_shishen, ['正财', '偏财'])
            )
            {
                $result[] = 20;
            }
        }

        /**
         * 检测年宫是否动
         */
        if ($donggong[1] > 0)
        {
            $shangshen_cai = $shangshen['正财'] + $shangshen['偏财'];
            $shangshen_yin = $shangshen['正印'] + $shangshen['偏印'];
            // 年宫是否受伤（流年）
            if ($shanggong[0] > 0)
            {
                // 财印是否受伤
                // 父亲健康  财受伤高于印
                if ($shangshen_cai > $shangshen_yin)
                {
                    $result[] = 21;
                }// 母亲健康 印高于财
                elseif ($shangshen_yin > $shangshen_cai)
                {
                    $result[] = 22;
                } // 都无
                else
                {
                    // 财印是否在流干
                    // 父亲健康 财
                    if (in_array($liugan_shishen, ['正财', '偏财']))
                    {
                        $result[] = 21;
                    }// 母亲健康 印
                    elseif (in_array($liugan_shishen, ['正印', '正印']))
                    {
                        $result[] = 22;
                    }// 否
                    else
                    {
                        // 年宫受伤度高于1
                        if ($shanggong[0] > 1)
                        {
                            $result[] = 23;
                        }
                    }
                }
            } else
            {
                // 财印是否受伤
                // 父亲健康  财受伤高于印且高于1
                if ($shangshen_cai > $shangshen_yin && $shangshen_cai >= 1)
                {
                    $result[] = 21;
                }// 母亲健康  印受伤高于财且高于1
                elseif ($shangshen_yin > $shangshen_cai && $shangshen_yin >= 1)
                {
                    $result[] = 22;
                }
            }
        }

        /**
         * 16岁以上45岁以下，检测时宫是否动
         */
        $yearsold = $this->option['advance']['year'] - $this->option['recode']['year'];
        if ($yearsold > 16 && $yearsold < 45 && $donggong[3] > 0)
        {
            // 子女星（男官杀，女食伤）是否动
            if (($this->option['recode']['type'] == 1 && $dongshen['正官'] + $dongshen['七杀'] > 0)
                || ($this->option['recode']['type'] != 1 && $dongshen['食神'] + $dongshen['伤官'] > 0))
            {
                // 子女问题 男  星/宫在流年同时受伤
                if ($this->option['recode']['type'] == 1 && $shanggong[3] > 0 && $shangshen['正官'] + $shangshen['七杀'] > 0)
                {
                    $result[] = 25;
                }// 孕育问题 女  星/宫在流年同时受伤
                elseif ($this->option['recode']['type'] != 1 && $shanggong[3] > 0 && $shangshen['食神'] + $shangshen['伤官'] > 0)
                {
                    $result[] = 24;
                }
                // 女食神男正官在流年受伤高于1
                // 子女问题
                elseif ($this->option['recode']['type'] == 1 && $shangshen['正官'] > 1)
                {
                    $result[] = 25;
                } // 孕育问题
                elseif ($this->option['recode']['type'] != 1 && $shangshen['食神'] > 1)
                {
                    $result[] = 24;
                } // 其它
                else
                {
                    // 子女1 子女星动指数高于0.5
                    if (
                        ($this->option['recode']['type'] == 1 && $dongshen['正官'] + $dongshen['七杀'] > 0)
                        || ($this->option['recode']['type'] != 1 && $dongshen['食神'] + $dongshen['食神'] > 0)
                    )
                    {
                        $result[] = 26;
                    }// 子女2 低于0.5
                    else
                    {
                        $result[] = 27;
                    }
                }
            }
        }

        /**
         * 疾病
         *  流年有七杀或伤官，且日干禄或日支在流年受伤高于0.5
         */
        if (
            (in_array($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan], ['七杀', '伤官'])
                || in_array($this->param['shishen'][$liu[0]][$rigan], ['七杀', '伤官']))
            &&
            (
                ($this->is_lushen($rigan, $bazi[2])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan]] >= 0.5)
                || ($this->is_lushen($rigan, $bazi[4])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan]] >= 0.5)
                || ($this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan]] >= 0.5)
                || ($this->is_lushen($rigan, $bazi[8])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan]] >= 0.5)
                || ($this->is_lushen($rigan, $liu[1])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan]] >= 0.5)
                || ($this->data['dayun_now'] != null
                    && $this->is_lushen($rigan, $this->data['dayun_now'][1])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan]] >= 0.5))
        )
        {
            $result[] = 32;
        }

        return array_unique($result);
    }

    /**
     * 获取用户八字数据
     * @return array
     */
    public function getUserData()
    {
        $this->option['liunian_realtime'] = true;
        $this->getAllData();

        $return = [
            'birth_time' => date('Y.m.d H:i', $this->data['birth_time']),
            'sex' => $this->option['recode']['type'],
            'bazi' => $this->data['bazi'],
        ];
        $shishen = $this->getShishen();
        $shishen1 = [
            $this->shishenToEasy($shishen['gan'][1]['relation']),
            $this->shishenToEasy($shishen['gan'][3]['relation']),
            '日元',
            $this->shishenToEasy($shishen['gan'][7]['relation']),
        ];
        $shishen2 = [];
        foreach ($shishen['cang'] as $k => $cang)
        {
            $shishen2[$k] = '';
            foreach ($cang as $cg)
            {
                $shishen2[$k] .= $this->shishenToEasy($cg['relation']);
            }
        }
        // 食神关系
        $return['shishen1'] = $shishen1;
        $return['shishen2'] = array_values($shishen2);
        //  藏干
        $return['canggan'] = [
            $this->param['canggan'][$this->data['bazi'][2]],
            $this->param['canggan'][$this->data['bazi'][4]],
            $this->param['canggan'][$this->data['bazi'][6]],
            $this->param['canggan'][$this->data['bazi'][8]],
        ];

        // 长生十二宫
        $return['changsheng'] = [
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][2]],
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][4]],
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][6]],
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][8]],
        ];
        // 纳音关系
        $return['nayin'] = [
            $this->getNayin($this->data['bazi'][1], $this->data['bazi'][2]),
            $this->getNayin($this->data['bazi'][3], $this->data['bazi'][4]),
            $this->getNayin($this->data['bazi'][5], $this->data['bazi'][6]),
            $this->getNayin($this->data['bazi'][7], $this->data['bazi'][8]),
        ];
        // 空亡
        $return['kongwang'] = [
            $this->getKongwang($this->data['bazi'][1], $this->data['bazi'][2]),
            $this->getKongwang($this->data['bazi'][3], $this->data['bazi'][4]),
            $this->getKongwang($this->data['bazi'][5], $this->data['bazi'][6]),
            $this->getKongwang($this->data['bazi'][7], $this->data['bazi'][8]),
        ];

        $this->getWuxingPercent();
        $return['wuxing'] = $this->data['wuxing_perc'];
        $return['start_time'] = date('Y.m.d', $this->data['st_time']);
        $return['start_year_old'] = sprintf("%.1f", abs($this->data['st_time'] - $this->data['birth_time']) / (3600 * 24 * 365)) * 1;
        $return['geju'] = $this->getStructure();

        $nowYear = intval(date('Y'));
        // 大运
        $st_year = intval(date('Y', $this->data['st_time']));// 大运起
        $num = 0;
        $d_status = $l_status = -1;
        for ($j = $st_year; $j <= $st_year + 50; $j += 10)
        {
            if ($d_status === -1 && $nowYear >= $j && $nowYear < $j + 10) $d_status = 0;
            elseif ($st_year > $nowYear || ($d_status === 0 && $nowYear < $j)) $d_status = 1;

            $return['dayun'][0][] = ['name' => $this->data['dayun'][$num], 'status' => $d_status];
            // 大运 干支
            $return['dayun'][1][] = ['name' => $j, 'status' => $d_status];

            // 流年数据
            $s = 2;
            for ($i = $j; $i < $j + 10; $i++)
            {
                $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($i)];
                if ($l_status === -1 && $d_status === 0 && $y_gan_zhi === $this->data['liunian_now'][0] . $this->data['liunian_now'][1]) $l_status = 0;
                elseif ($l_status === 0 || $j > $nowYear) $l_status = 1;

                $return['dayun'][$s][] = ['name' => $y_gan_zhi, 'status' => $l_status];
                $s++;
            }
            $return['dayun'][12][] = ['name' => $i - 1, 'status' => $d_status];
            $num++;
        }

        return $return;
    }

    /**
     * 桃花
     * @return int
     */
    public function getTaohua()
    {
        $this->getAllData();
        $st_year = date('Y', $this->data['st_time']);
        for ($i = $st_year; $i < $this->option['advance']['year']; $i += 10) if ($this->option['advance']['year'] >= $i && $this->option['advance']['year'] < $i + 10) $st_year = $i;

        $d_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($st_year)];
        $d_gan = mb_substr($d_gan_zhi, 0, 1, 'utf-8');
        $d_zhi = mb_substr($d_gan_zhi, 1, 1, 'utf-8');
        $dazhi = $this->param['canggan'][$d_zhi][0];

        $taohua = 0;
        $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($this->option['advance']['year'])];
        $y_gan = mb_substr($y_gan_zhi, 0, 1, 'utf-8');
        $y_zhi = mb_substr($y_gan_zhi, 1, 1, 'utf-8');
        $liuzhi = $this->param['canggan'][$y_zhi][0];
        $rizhi = $this->param['canggan'][$this->data['bazi'][6]][0];

        if (

            ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '正财'
                    || $this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '偏财'))
            ||

            ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '七杀'
                    || $this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '正官'))
        )
        {
            $taohua += 15;

            if ($this->is_lushen($this->data['bazi'][5], $y_zhi))
            {
                $taohua += 15;
            }

            if ($this->data['bazi'][6] == $y_zhi)
            {
                $taohua += 12;
            }
        }

        if (

            ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正财'
                    || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '偏财'))
            ||

            ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '七杀'
                    || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正官'))
        )
        {
            $taohua += 12;

            if ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '比肩')
            {
                $taohua += 13;
            }

            if ($this->is_liuhe($y_gan, $this->data['bazi'][5]))
            {
                $taohua += 15;
            }
        }

        if ($this->is_liuhe($y_zhi, $this->data['bazi'][6]))
        {
            $taohua += 8;

            if ($this->is_liuhe($y_gan, $this->data['bazi'][5]))
            {
                $taohua += 8;
            }

            if (

                ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正财'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '偏财'))
                ||

                ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '七杀'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正官'))
            )
            {
                $taohua += 8;
            }
        }

        if ($this->is_liuchong($y_zhi, $this->data['bazi'][6]))
        {
            if (

                ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正财'
                        || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '偏财'))
                ||

                ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '七杀'
                        || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正官'))
            )
            {
                $taohua += 7;
            }
            if (

                ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正财'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '偏财'))
                ||

                ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '七杀'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正官'))
            )
            {
                $taohua += 7;
            }

            if ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '比肩')
            {
                $taohua += 7;
            }

            if (
                $this->is_liuhe($this->data['bazi'][6], $this->data['bazi'][2])
                || $this->is_liuhe($this->data['bazi'][6], $this->data['bazi'][4])
                || $this->is_liuhe($this->data['bazi'][6], $this->data['bazi'][8])
            )
            {
                $taohua += 7;
            }

            if (in_array($this->data['bazi'][6], ['辰', '戌', '丑', '未']))
            {
                $taohua += 3;
            }
        }

        if ($this->is_taohua($this->data['bazi'][6], $y_zhi))
        {
            $taohua += 5;
        }

        if (
            $this->is_taohua($this->data['bazi'][2], $y_zhi)
            && (
                $this->data['bazi'][4] == $y_zhi
                || $this->data['bazi'][4] == $y_zhi
                || $this->data['bazi'][4] == $y_zhi
                || $d_zhi == $y_zhi
            )
        )
        {
            $taohua += 5;
        }

        $temp_arr = [$this->data['bazi'][2], $this->data['bazi'][4], $this->data['bazi'][6], $this->data['bazi'][8], $d_zhi];

        if (

            $this->is_liuhe($y_zhi, $this->data['bazi'][2]) &&

            ($this->is_liuchong($this->data['bazi'][2], $temp_arr) || $this->is_liuhai($this->data['bazi'][2], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][2]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][2]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $this->data['bazi'][4]) &&

            ($this->is_liuchong($this->data['bazi'][4], $temp_arr) || $this->is_liuhai($this->data['bazi'][4], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][4]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][4]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $this->data['bazi'][6]) &&

            ($this->is_liuchong($this->data['bazi'][6], $temp_arr) || $this->is_liuhai($this->data['bazi'][6], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][6]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][6]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $this->data['bazi'][8]) &&

            ($this->is_liuchong($this->data['bazi'][8], $temp_arr) || $this->is_liuhai($this->data['bazi'][8], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][8]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][8]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $d_zhi) &&

            ($this->is_liuchong($d_zhi, $temp_arr) || $this->is_liuhai($d_zhi, $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        }

        if (
            ($this->option['recode']['type'] == 1 && in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['偏财', '正财']))
            || ($this->option['recode']['type'] == 2 && in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['七杀', '正官']))
        )
        {
            if ($this->is_liuhe($y_zhi, $d_zhi))
            {
                $taohua += 10;
            }
            if ($this->is_gong($y_zhi, $d_zhi))
            {
                $taohua += 7;
            }
            if ($this->is_liuchong($y_zhi, $d_zhi))
            {
                $taohua += 5;
            }
        }

        if (
            (($this->option['recode']['type'] == 1 && in_array($this->param['shishen'][$y_gan][$this->data['bazi'][5]], ['偏财', '正财']))
                || ($this->option['recode']['type'] == 2 && in_array($this->param['shishen'][$y_gan][$this->data['bazi'][5]], ['七杀', '正官'])))
            && (
                $this->is_lushen($y_gan, $this->data['bazi'][2])
                || $this->is_lushen($y_gan, $this->data['bazi'][4])
                || $this->is_lushen($y_gan, $this->data['bazi'][6])
                || $this->is_lushen($y_gan, $this->data['bazi'][8])
                || $this->is_lushen($y_gan, $d_zhi)
            )
        )
        {
            $taohua += 8;
        }

        if ($this->is_lushen($y_gan, $this->data['bazi'][6]))
        {
            $taohua += 9;
        }

        if (
            in_array($this->data['bazi'][6], ['辰', '戌', '丑', '未'])
            && in_array($y_gan, [$this->param['canggan'][$this->data['bazi'][6]][1], $this->param['canggan'][$this->data['bazi'][6]][2]])
        )
        {
            $taohua += 7;

            if ($this->data['bazi'][5] == '壬' || $this->data['bazi'][5] == '癸')
            {
                $taohua += 3;
            }
        }

        if (in_array($y_zhi, $temp_arr) &&
            (($this->option['recode']['type'] == 1 && in_array($this->param['shishen'][$liuzhi][$this->data['bazi'][5]], ['偏财', '正财']))
                || ($this->option['recode']['type'] == 2 && in_array($this->param['shishen'][$liuzhi][$this->data['bazi'][5]], ['七杀', '正官'])))

        )
        {
            $taohua += 6;
        }

        if ($this->data['bazi'][6] == $y_zhi)
        {
            $taohua += 6;
        }

        if ($this->is_gong($this->data['bazi'][6], $y_zhi))
        {
            $taohua += 6;
        }

        if ($this->is_liuhe($y_zhi, $d_zhi) || $this->is_liuchong($y_zhi, $d_zhi))
        {
            if ($this->param['shishen'][$d_gan][$this->data['bazi'][5]] == '比肩')
            {
                $taohua += 3;
                if ($this->is_liuhe($this->data['bazi'][6], $d_zhi) || $this->is_gong($this->data['bazi'][6], $d_zhi))
                {
                    $taohua += 6;
                }
                if (
                    (
                        ($this->is_liuhe($this->data['bazi'][1], $d_zhi)
                            || $this->is_gong($this->data['bazi'][1], $d_zhi))
                        && in_array($this->param['shishen'][$this->data['bazi'][1]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][3], $d_zhi)
                            || $this->is_gong($this->data['bazi'][3], $d_zhi))
                        && in_array($this->param['shishen'][$this->data['bazi'][3]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][7], $d_zhi)
                            || $this->is_gong($this->data['bazi'][7], $d_zhi))
                        && in_array($this->param['shishen'][$this->data['bazi'][7]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][2], $d_zhi)
                            || $this->is_gong($this->data['bazi'][2], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][2]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][4], $d_zhi)
                            || $this->is_gong($this->data['bazi'][4], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][4]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][6], $d_zhi)
                            || $this->is_gong($this->data['bazi'][6], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][6]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][8], $d_zhi)
                            || $this->is_gong($this->data['bazi'][8], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][8]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                )
                {
                    $taohua += 6;
                }
            }
        }

        $advance = [
            'year' => $this->option['advance']['year'],
            'month' => 4,
            'day' => 1,
            'hour' => 12,
            'minute' => 0,
            'timezone' => $this->option['advance']['timezone'] ?? 8,
            'is_summer' => $this->option['advance']['is_summer'] ?? 0,
        ];

        $Astrolog = Astrolog::getInstance();
        $Astrolog->setRecode1($this->option['recode'])
            ->setAdvance($advance)
            ->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(false)
            ->setUserSetting(config('astroset.setting1'))
            ->setGetDatas(['thirdprogressed'])
            ->getAstroDatas();

        $th_4_1 = $Astrolog->getDatas('thirdprogressed')['planets'];

        $advance['month'] = 10;
        $th_10_1 = $Astrolog->getDatas('thirdprogressed')['planets'];

        $score_4_1 = 0;
        $score_10_1 = 0;
        if (isset($th_4_1[0]['phase']['0-3']) && $th_4_1[0]['phase']['0-3']['phase_e'] == 0)
        {
            $score_4_1 += 5;
            if (isset($th_4_1[3]['phase']['3-5'])) $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if (isset($th_4_1[3]['phase']['3-4']) && $th_4_1[3]['phase']['3-4']['phase_e'] == 0)
        {
            $score_4_1 += 5;
            if (isset($th_4_1[3]['phase']['3-5'])) $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if (isset($th_4_1[0]['phase']['0-4']) && $th_4_1[0]['phase']['0-4']['phase_e'] == 0)
        {
            $score_4_1 += 2;
            if (isset($th_4_1[4]['phase']['4-5'])) $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7]) || in_array($th_4_1[4]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if ($score_4_1 == 0 && isset($th_4_1[3]['phase']['3-5']))
        {
            $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7]) || in_array($th_4_1[5]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if (isset($th_10_1[0]['phase']['0-3']) && $th_10_1[0]['phase']['0-3']['phase_e'] == 0)
        {
            $score_10_1 += 5;
            if (isset($th_10_1[3]['phase']['3-5'])) $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if (isset($th_10_1[3]['phase']['3-4']) && $th_10_1[3]['phase']['3-4']['phase_e'] == 0)
        {
            $score_10_1 += 5;
            if (isset($th_10_1[3]['phase']['3-5'])) $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if (isset($th_10_1[0]['phase']['0-4']) && $th_10_1[0]['phase']['0-4']['phase_e'] == 0)
        {
            $score_10_1 += 2;
            if (isset($th_10_1[4]['phase']['4-5'])) $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7]) || in_array($th_10_1[4]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if ($score_10_1 == 0 && isset($th_10_1[3]['phase']['3-5']))
        {
            $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7]) || in_array($th_10_1[5]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if ($score_4_1 > $score_10_1)
        {
            $taohua += $score_4_1;
        } else
        {
            $taohua += $score_10_1;
        }
        return $taohua;
    }

    /**
     * 获取当前的所有大运流年等信息
     */
    private function getAllData()
    {
        // 获取大运的起运时间
        $this->dayun();
        // 获取八字五行比例
        $this->getWuxingPercent();
        // 日干禄神
//        $this->data['lushen'] = $this->lushen();
        // 运势年份
        $year = $this->option['advance']['year'];
        // 大运的起运年
        $st_year = date('Y', $this->data['st_time']);
        // 获取当前所在大运
        if ($year > $st_year)
        {
            // 大运 干支
            $d_gan_zhi = $this->data['dayun'][floor(($year - $st_year) / 10)];

            // 大运天干
            $d_gan = mb_substr($d_gan_zhi, 0, 1, 'utf-8');
            // 大运地支
            $d_zhi = mb_substr($d_gan_zhi, 1, 1, 'utf-8');

            $this->data['dayun_now'] = [$d_gan, $d_zhi];
        }

        $liunian_year_stem_branche = $this->getYearStemBranche($year);

        if ($this->option['liunian_realtime'] === true)
        {
            // 获取命主太阳度数
            $sunDeg = (Astrolog::getInstance())->setRecode1($this->option['advance'])
                    ->setExecPrefix(config('astrolog.prefix'))
                    ->setIsAstrolabe(false)
                    ->setUserSetting(config('astroset.setting1'))
                    ->getPlanetOriginData('0')[0] * 1;

            if ($this->option['advance']['month'] < 3 && $sunDeg < 315)
            {
                $liunian_year_stem_branche--;

                if ($liunian_year_stem_branche < 0) $liunian_year_stem_branche = 59;
            }
        }
        // 流年 干支
        $y_gan_zhi = $this->param['chinese_era'][$liunian_year_stem_branche];
        // 流年天干
        $y_gan = mb_substr($y_gan_zhi, 0, 1, 'utf-8');
        // 流年地支
        $y_zhi = mb_substr($y_gan_zhi, 1, 1, 'utf-8');
        $this->data['liunian_now'] = [$y_gan, $y_zhi];
        return;
    }

    private function getyearConclusionData()
    {
        $this->data['shenwang'] = $this->is_shenwang();
        $this->data['liunianzhushen'] = $this->getZhuShen();
        $this->data['ganzhibuxie'] = $this->is_ganzhibuxie();
        $this->data['anjing'] = $this->is_anjing();
        $this->data['donggong'] = $this->donggong();
        $this->data['dongshen'] = $this->dongshen();
        $this->shanggong_shangshen();
        return;
    }

    /**
     * 动宫
     * 流年与八字原局某柱形成干合、支合、支冲、支穿、支拱，支刑、出干、入支、现干、现支则计算动宫指数
     * 干合1
     * 支合1
     * 支冲1
     * 支穿0.5
     * 支拱0.4
     * 支刑
     *    如命运年凑齐三刑1
     *    如未凑齐则0.5
     * 出干0.5 是指流干之禄是命局某柱地支
     * 入支0.5 是指流支是命局某柱天干之禄
     * 现干0.8 流干为某柱天干
     * 现支0.8 流支为某柱地支
     *
     */
    public function donggong()
    {
        $liu = $this->data['liunian_now'];

        $ming_zhu = [
            [$this->data['bazi'][1], $this->data['bazi'][2],],
            [$this->data['bazi'][3], $this->data['bazi'][4],],
            [$this->data['bazi'][5], $this->data['bazi'][6],],
            [$this->data['bazi'][7], $this->data['bazi'][8],],
        ];
        $score = [0, 0, 0, 0];
        foreach ($ming_zhu as $k => $mzhu)
        {
            if ($this->is_wuhe($liu[0], $mzhu[0]))
            {
                $score[$k] += 1;
            }
            if ($this->is_liuhe($liu[1], $mzhu[1]))
            {
                $score[$k] += 1;
            }
            if ($this->is_liuchong($liu[1], $mzhu[1]))
            {
                $score[$k] += 1;
            }
            if ($this->is_liuhai($liu[1], $mzhu[1]))
            {
                $score[$k] += 0.5;
            }
            if ($this->is_gong($liu[1], $mzhu[1]))
            {
                $score[$k] += 0.4;
            }
            if ($this->is_xing($liu[1], $mzhu[1]))
            {
                if ($this->data['dayun_now'] != null
                    && $this->is_sanxing($liu[1], $mzhu[1], $this->data['dayun_now'][1]))
                {
                    $score[$k] += 1;
                } else
                {
                    $score[$k] += 0.5;
                }
            }
            if ($this->is_lushen($liu[0], $mzhu[1]))
            {
                $score[$k] += 0.5;
            }
            if ($this->is_lushen($liu[1], $mzhu[0]))
            {
                $score[$k] += 0.5;
            }
            if ($liu[0] == $mzhu[0])
            {
                $score[$k] += 0.8;
            }
            if ($liu[1] == $mzhu[0])
            {
                $score[$k] += 0.8;
            }
        }
        return $score;
    }

    /**
     * 动神
     * 比肩、劫财、食神、伤官、偏财、正财、七杀、正官、偏印、正印
     * 流干出现+0.6
     * 流支本气出现+0.5
     * 命运某干被流干合，相合双方均+0.5
     * 命运某支被流支冲合，相冲相合双方本气+0.5
     * 命运某支被流支拱，被拱者本气+0.3
     * 命运某支被流支刑穿，相刑穿双方本气+0.3
     *      如凑齐三刑改为0.5
     */
    public function dongshen()
    {
        $liu = $this->data['liunian_now'];

        $liuzhi_benqi = $this->param['canggan'][$liu[1]][0];

        $rigan = $this->data['bazi'][5];

        $zhus = [
            [$this->data['bazi'][1], $this->data['bazi'][2],],
            [$this->data['bazi'][3], $this->data['bazi'][4],],
            [$this->data['bazi'][5], $this->data['bazi'][6],],
            [$this->data['bazi'][7], $this->data['bazi'][8],],
        ];

        $score = [
            '比肩' => 0, '劫财' => 0,
            '食神' => 0, '伤官' => 0,
            '偏财' => 0, '正财' => 0,
            '七杀' => 0, '正官' => 0,
            '偏印' => 0, '正印' => 0,
        ];
        // 流干出现+0.6
        $score[$this->param['shishen'][$liu[0]][$rigan]] += 0.6;
        // 流支本气出现+0.5
        $score[$this->param['shishen'][$liuzhi_benqi][$rigan]] += 0.5;

        if ($this->data['dayun_now'] != null)
        {
            $zhus[] = $this->data['dayun_now'];
        }

        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];
        $liuzhi_shishen = $this->param['shishen'][$liuzhi_benqi][$rigan];

        foreach ($zhus as $k => $zhu)
        {
            $zhugan_shishen = $this->param['shishen'][$zhu[0]][$rigan];
            $zhuzhi_shishen = $this->param['shishen'][$this->param['canggan'][$zhu[1]][0]][$rigan];

            if ($this->is_wuhe($zhu[0], $liu[0]))
            {
                // 命运某干被流干合，相合双方均+0.5
                $score[$liugan_shishen] += 0.5;
                // 命运某干被流干合，相合双方均+0.5  日干不加分
                if ($k != 2) $score[$zhugan_shishen] += 0.5;
            }
            // 命运某支被流支冲合，相冲相合双方本气+0.5
            if ($this->is_liuchong($liu[1], $zhu[1]) || $this->is_liuhe($liu[1], $zhu[1]))
            {
                $score[$liuzhi_shishen] += 0.5;
                $score[$zhuzhi_shishen] += 0.5;
            }
            // 命运某支被流支拱，被拱者本气+0.3
            if ($this->is_gong($liu[1], $zhu[1]) || $this->is_liuhe($liu[1], $zhu[1]))
            {
                $score[$zhuzhi_shishen] += 0.3;
            }
            // 命运某支被流支刑穿，相刑穿双方本气+0.3  如凑齐三刑改为0.5
            if ($this->is_xing($liu[1], $zhu[1]) || $this->is_liuhai($liu[1], $zhu[1]))
            {
                if (($this->data['dayun_now'] != null
                        && $this->is_sanxing($liu[1], $zhu[1], $this->data['dayun_now'][1]))
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][2])
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][4])
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][6])
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][8])
                )
                {
                    $score[$liuzhi_shishen] += 0.5;
                    $score[$zhuzhi_shishen] += 0.5;
                } else
                {
                    $score[$liuzhi_shishen] += 0.3;
                    $score[$zhuzhi_shishen] += 0.3;
                }
            }
        }
        return $score;
    }

    /**
     * 伤宫/伤神
     * 计算原局受伤度
     *   天干
     *      坐下地支是该干死绝病地或被坐下地支截脚0.5
     *          截脚是地支本气与天干本气同性且克之 天干是坐支本气的偏财
     *      被邻干合克或正克1
     *      被非邻干合克或正克0.5
     *      被月柱本气克0.5
     *      被运干正克0.5
     *      被运干生0.3
     *      被邻干生-0.4
     *      月柱或坐下有该干的根-0.4（如果是禄-1）
     *      该干在地支有根且受地支本气生两次或以上-0.5
     *   地支
     *      被盖头0.5
     *          盖头是同柱天干与该地支本气相同并克之
     *      被邻支或运支刑冲穿1
     *          且克+0.5
     *      被非邻支刑冲穿0.8
     *          且克+0.4
     *   宫位受伤度为该柱天干地支受伤之合
     *   十神受伤度是天干地支本气十神的受伤度
     *      如命局有多个该十神，取受伤最高者
     * 计算流年受伤度
     *   流支与命运某柱刑+0.3（凑齐三刑改为0.5）冲+0.5穿+0.5（原局受作用的地支本气与宫位受伤度均+相应值）
     *      存在干支不协或双冲+1
     * 流干如为原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度
     * 流干如正克或合克原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度+0.3
     * 相穿呼应
     *   如本命出现两地支相穿，大运地支与流年地支分别是相穿的两地支，本命相穿两宫两支本气各+1破坏度
     *   如本命出现两地支相穿，流支为相穿地支之一，流干的禄为相穿地支的另一个，本命相穿两宫两支本气各+1破坏度
     *   如本命与大运地支相穿，流支为相穿地支之一，两穿地支及本命被穿宫位各+1破坏度
     * 计算年月日时各宫在流年的受伤指数
     * 计算各十神在流年的受伤指数
     */
    public function shanggong_shangshen()
    {
        $liu = $this->data['liunian_now'];
        $rigan = $this->data['bazi'][5];
        $changsheng = $this->param['changsheng'];
        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];

        $ming_zhu = [
            [$this->data['bazi'][1], $this->data['bazi'][2],],
            [$this->data['bazi'][3], $this->data['bazi'][4],],
            [$this->data['bazi'][5], $this->data['bazi'][6],],
            [$this->data['bazi'][7], $this->data['bazi'][8],],
        ];
        $gong_score = [0, 0, 0, 0];
        $shen_score = [
            '比肩' => 0, '劫财' => 0,
            '食神' => 0, '伤官' => 0,
            '偏财' => 0, '正财' => 0,
            '七杀' => 0, '正官' => 0,
            '偏印' => 0, '正印' => 0,
        ];

        // 计算原局受伤度
        foreach ($ming_zhu as $k => $mzhu)
        {
            $shen_score_temp = [
                '比肩' => 0, '劫财' => 0,
                '食神' => 0, '伤官' => 0,
                '偏财' => 0, '正财' => 0,
                '七杀' => 0, '正官' => 0,
                '偏印' => 0, '正印' => 0,
            ];

            $zhi_benqi = $this->param['canggan'][$mzhu[1]][0];

            $zhugan_shishen = $this->param['shishen'][$mzhu[0]][$rigan];
            // 坐下地支是该干死绝病地或被坐下地支截脚0.5
            // 截脚：天干是坐支本气的偏财
            if (in_array($changsheng[$mzhu[0]][$mzhu[1]], ['死', '绝', '病 '])
                || $this->is_jiejiao($mzhu[0], $mzhu[1]))
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            /**
             * 被邻干合克或正克1
             * A干被合克，是A干被对方合，同时对方是A干的正官
             * 合克，就是天干五合带克，比如庚来合乙，庚合克乙
             * 正克是辛来克乙
             */
            $linggan = [];
            $lingzhi = [];
            $is_linggan_heke = false;
            if (isset($ming_zhu[$k - 1]))
            {
                $linggan[] = $ming_zhu[$k - 1][0];
                $lingzhi[] = $ming_zhu[$k - 1][1];
            }
            if (isset($ming_zhu[$k + 1]))
            {
                $linggan[] = $ming_zhu[$k + 1][0];
                $lingzhi[] = $ming_zhu[$k + 1][1];
            }
            foreach ($linggan as $lg)
            {
                if (($this->is_wuhe($lg, $mzhu[0]) && $this->param['shishen'][$lg][$mzhu[0]] == '正官')
                    || $this->param['shishen'][$lg][$mzhu[0]] == '七杀')
                {
                    $is_linggan_heke = true;
                }
            }
            if ($is_linggan_heke)
            {
                $gong_score[$k] += 1;
                $shen_score_temp[$zhugan_shishen] += 1;
            }
            /**
             * 被非邻干合克或正克0.5
             */
            $is_fei_linggan_heke = false;
            $feilinggan = [];
            $feilingzhi = [];
            if (isset($ming_zhu[$k - 2]))
            {
                $feilinggan[] = $ming_zhu[$k - 2][0];
                $feilingzhi[] = $ming_zhu[$k - 2][1];
            }
            if (isset($ming_zhu[$k - 3]))
            {
                $feilinggan[] = $ming_zhu[$k - 3][0];
                $feilingzhi[] = $ming_zhu[$k - 3][1];
            }
            if (isset($ming_zhu[$k + 2]))
            {
                $feilinggan[] = $ming_zhu[$k + 2][0];
                $feilingzhi[] = $ming_zhu[$k + 2][1];
            }
            if (isset($ming_zhu[$k + 3]))
            {
                $feilinggan[] = $ming_zhu[$k + 3][0];
                $feilingzhi[] = $ming_zhu[$k + 3][1];
            }

            foreach ($feilinggan as $flg)
            {
                if (($this->is_wuhe($flg, $mzhu[0]) && $this->param['shishen'][$flg][$mzhu[0]] == '正官')
                    || $this->param['shishen'][$flg][$mzhu[0]] == '七杀')
                {
                    $is_fei_linggan_heke = true;
                }
            }
            if ($is_fei_linggan_heke)
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            // 被月柱本气克0.5
            $yuezhu_benqi = $this->param['canggan'][$this->data['bazi'][4]][0];
            if (in_array($this->param['shishen'][$yuezhu_benqi][$mzhu[0]], ['七杀', '正官']))
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            // 被运干正克0.5
            if ($this->data['dayun_now'] != null
                && $this->param['shishen'][$this->data['dayun_now'][0]][$mzhu[0]] == '七杀')
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            // 被运干生0.3
            if ($this->data['dayun_now'] != null
                && in_array($this->param['shishen'][$this->data['dayun_now'][0]][$mzhu[0]], ['正印', '偏印']))
            {
                $gong_score[$k] += 0.3;
                $shen_score_temp[$zhugan_shishen] += 0.3;
            }
            // 被邻干生-0.4
            $is_linggan_sheng = false;
            foreach ($linggan as $lg)
            {
                if (in_array($this->param['shishen'][$lg][$mzhu[0]], ['正印', '偏印']))
                {
                    $is_linggan_sheng = true;
                }
            }
            if ($is_linggan_sheng)
            {
                $gong_score[$k] += -0.4;
                $shen_score_temp[$zhugan_shishen] += -0.4;
            }
            /**
             * 月柱或坐下有该干的根-0.4（如果是禄-1）
             * (如果某地支含有与某天干相同的五行，就是该天干的根)
             */
            $is_yuezhu_zuoxia_yougen = false;
            $is_lushen = false;
            $is_yougen = false;
            $mzhu_sheng_num = 0;

            foreach ($ming_zhu as $k2 => $mzhu2)
            {
                $canggan = $this->param['canggan'][$mzhu2[1]];

                foreach ($canggan as $cg)
                {
                    if ($is_yuezhu_zuoxia_yougen === false
                        && $this->param['wuxing'][$cg] == $this->param['wuxing'][$mzhu[0]])
                    {
                        $is_yougen = true;
                        // 月柱 或 坐下
                        if ($k2 == 1 || $k == $k2)
                        {
                            $is_yuezhu_zuoxia_yougen = true;
                            if ($this->is_lushen($mzhu[0], $mzhu2[1]))
                            {
                                $is_lushen = true;
                            }
                        }
                    }
                }
                if (in_array($this->param['shishen'][$canggan[0]][$mzhu[0]], ['正印', '偏印']))
                {
                    $mzhu_sheng_num++;
                }
            }
            if ($is_yuezhu_zuoxia_yougen)
            {
                if ($is_lushen)
                {
                    $gong_score[$k] += -1;
                    $shen_score_temp[$zhugan_shishen] += -1;
                } else
                {
                    $gong_score[$k] += -0.4;
                    $shen_score_temp[$zhugan_shishen] += -0.4;
                }
            }
            // 该干在地支有根且受地支本气生两次或以上-0.5
            if ($is_yougen && $mzhu_sheng_num >= 2)
            {
                $gong_score[$k] += -0.5;
                $shen_score_temp[$zhugan_shishen] += -0.5;
            }
            // 当前地支本气的十神
            $dizhi_benqi_shishen = $this->param['shishen'][$zhi_benqi][$rigan];
            // 地支
            //	被盖头0.5 盖头是同柱天干与该地支本气相同并克之
            //	被邻支或运支刑冲穿1
            //		且克+0.5
            //	被非邻支刑冲穿0.8
            //		且克+0.4
            if ($this->is_gaitou($mzhu[0], $mzhu[1]))
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$dizhi_benqi_shishen] += 0.5;
            }
            $is_lingzhi_xcc = false;
            $is_lingzhi_xcc_and_ke = false;
            if ($this->data['dayun_now'] != null && ($this->is_xing($mzhu[1], $this->data['dayun_now'][1])
                    || $this->is_liuchong($mzhu[1], $this->data['dayun_now'][1])
                    || $this->is_liuhai($mzhu[1], $this->data['dayun_now'][1])))
            {
                $is_lingzhi_xcc = true;
                if (in_array($this->param['shishen'][$mzhu[0]][$this->param['canggan'][$this->data['dayun_now'][1]][0]],
                    ['正官', '七杀', '偏财', '正财']))
                {
                    $is_lingzhi_xcc_and_ke = true;
                }
            }
            if ($is_lingzhi_xcc === false)
            {
                foreach ($lingzhi as $lz)
                {
                    if ($is_lingzhi_xcc === false && ($this->is_xing($mzhu[1], $lz)
                            || $this->is_liuchong($mzhu[1], $lz)
                            || $this->is_liuhai($mzhu[1], $lz))
                    )
                    {
                        $is_lingzhi_xcc = true;
                        if (in_array($this->param['shishen'][$mzhu[0]][$this->param['canggan'][$lz][0]],
                            ['正官', '七杀', '偏财', '正财']))
                        {
                            $is_lingzhi_xcc_and_ke = true;
                        }
                    }
                }
            }
            // 被邻支或运支刑冲穿1
            if ($is_lingzhi_xcc)
            {
                $gong_score[$k] += 1;
                $shen_score_temp[$dizhi_benqi_shishen] += 1;
                // 且克+0.5
                if ($is_lingzhi_xcc_and_ke)
                {
                    $gong_score[$k] += 0.5;
                    $shen_score_temp[$dizhi_benqi_shishen] += 0.5;
                }
            }
            $is_feilingzhi_xcc = false;
            $is_feilingzhi_xcc_and_ke = false;
            foreach ($feilingzhi as $flz)
            {
                if ($is_feilingzhi_xcc === false && ($this->is_xing($mzhu[1], $flz)
                        || $this->is_liuchong($mzhu[1], $flz)
                        || $this->is_liuhai($mzhu[1], $flz))
                )
                {
                    $is_feilingzhi_xcc = true;
                    if (in_array($this->param['shishen'][$mzhu[0]][$this->param['canggan'][$flz][0]],
                        ['正官', '七杀', '偏财', '正财']))
                    {
                        $is_feilingzhi_xcc_and_ke = true;
                    }
                }
            }
            // 被非邻支刑冲穿0.8
            if ($is_feilingzhi_xcc)
            {
                $gong_score[$k] += 0.8;
                $shen_score_temp[$dizhi_benqi_shishen] += 0.8;
                // 且克 且克+0.4
                if ($is_feilingzhi_xcc_and_ke)
                {
                    $gong_score[$k] += 0.4;
                    $shen_score_temp[$dizhi_benqi_shishen] += 0.4;
                }
            }
            // 十神受伤度是天干地支本气十神的受伤度 如命局有多个该十神，取受伤最高者
            if ($shen_score[$zhugan_shishen] < $shen_score_temp[$zhugan_shishen])
            {
                $shen_score[$zhugan_shishen] = $shen_score_temp[$zhugan_shishen];
            }
            if ($shen_score[$dizhi_benqi_shishen] < $shen_score_temp[$dizhi_benqi_shishen])
            {
                $shen_score[$dizhi_benqi_shishen] = $shen_score_temp[$dizhi_benqi_shishen];
            }
        }

        // 计算流年受伤度
        $liu_gong_score = [0, 0, 0, 0];
        $liu_shen_score = [
            '比肩' => 0, '劫财' => 0,
            '食神' => 0, '伤官' => 0,
            '偏财' => 0, '正财' => 0,
            '七杀' => 0, '正官' => 0,
            '偏印' => 0, '正印' => 0,
        ];
        /**
         * 流支与命运某柱刑+0.3（凑齐三刑改为0.5）冲+0.5穿+0.5（原局受作用的地支本气与宫位受伤度均+相应值）
         *  存在干支不协或双冲或正冲+1
         * 正冲是 相冲的两柱天干相同，比如流年甲寅，本命甲申
         */
        foreach ($ming_zhu as $k1 => $mzhu)
        {
            $zhi_benqi = $this->param['canggan'][$mzhu[1]][0];

            // 当前地支本气的十神
            $dizhi_benqi_shishen = $this->param['shishen'][$zhi_benqi][$rigan];

            $zhugan_shishen = $this->param['shishen'][$mzhu[0]][$rigan];

            if ($this->is_xing($liu[1], $mzhu[1]))
            {
                if ($this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[0][1])
                    || $this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[1][1])
                    || $this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[2][1])
                    || $this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[3][1]))
                {
                    $liu_gong_score[$k1] += 0.5;
                    $liu_shen_score[$dizhi_benqi_shishen] += 0.5;

                    if ($this->data['ganzhibuxie'] === true
                        || $this->data['shuangchong'] === true
                        || $liu[0] == $mzhu[0]
                    )
                    {
                        $liu_gong_score[$k1] += 1;
                        $liu_shen_score[$dizhi_benqi_shishen] += 1;
                    }
                } else
                {
                    $liu_gong_score[$k1] += 0.3;
                    $liu_shen_score[$dizhi_benqi_shishen] += 0.3;

                    if ($this->data['ganzhibuxie'] === true
                        || $this->data['shuangchong'] === true
                        || $liu[0] == $mzhu[0]
                    )
                    {
                        $liu_gong_score[$k1] += 1;
                        $liu_shen_score[$dizhi_benqi_shishen] += 1;
                    }
                }
            } elseif ($this->is_liuchong($liu[1], $mzhu[1]))
            {
                $liu_gong_score[$k1] += 0.5;
                $liu_shen_score[$dizhi_benqi_shishen] += 0.5;
                if ($this->data['ganzhibuxie'] === true
                    || $this->data['shuangchong'] === true
                    || $liu[0] == $mzhu[0]
                )
                {
                    $liu_gong_score[$k1] += 1;
                    $liu_shen_score[$dizhi_benqi_shishen] += 1;
                }
            } elseif ($this->is_liuhai($liu[1], $mzhu[1]))
            {
                $liu_gong_score[$k1] += 0.5;
                $liu_shen_score[$dizhi_benqi_shishen] += 0.5;

                if ($this->data['ganzhibuxie'] === true
                    || $this->data['shuangchong'] === true
                    || $liu[0] == $mzhu[0])
                {
                    $liu_gong_score[$k1] += 1;
                    $liu_shen_score[$dizhi_benqi_shishen] += 1;
                }
            }
            // 流干如为原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度
            if ($liu[0] == $mzhu[0])
            {
                $liu_gong_score[$k1] += $gong_score[$k1];
                $liu_shen_score[$zhugan_shishen] += $shen_score[$zhugan_shishen];
            }
            // 流干如正克或合克原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度+0.3
            if (($this->is_wuhe($liu[0], $mzhu[0]) && $this->param['shishen'][$liu[0]][$mzhu[0]] == '正官')
                || $this->param['shishen'][$liu[0]][$mzhu[0]] == '七杀')
            {
                $liu_gong_score[$k1] += $gong_score[$k1] + 0.3;
                $liu_shen_score[$zhugan_shishen] += $shen_score[$zhugan_shishen] + 0.3;
            }

            /**
             * 流干如被原局某宫干正克
             *  流干支与该宫成双冲 该干十神流年受伤+1
             *  流支与命运某支刑冲穿 该干十神流年受伤+0.5
             */
            if ($this->param['shishen'][$mzhu[0]][$liu[0]] == '七杀')
            {
                if ($this->is_shuangchong($liu, [$mzhu]))
                {
                    $liu_shen_score[$liugan_shishen] += 0.5;
                }
            }
        }
        if (
            ($this->param['shishen'][$this->data['bazi'][1]][$liu[0]] == '七杀'
                || $this->param['shishen'][$this->data['bazi'][3]][$liu[0]] == '七杀'
                || $this->param['shishen'][$this->data['bazi'][5]][$liu[0]] == '七杀'
                || $this->param['shishen'][$this->data['bazi'][7]][$liu[0]] == '七杀'
            )
            &&
            (
                $this->is_xing($liu[1], $this->data['bazi'][2])
                || $this->is_liuchong($liu[1], $this->data['bazi'][2])
                || $this->is_liuhai($liu[1], $this->data['bazi'][2])
                || $this->is_xing($liu[1], $this->data['bazi'][4])
                || $this->is_liuchong($liu[1], $this->data['bazi'][4])
                || $this->is_liuhai($liu[1], $this->data['bazi'][4])
                || $this->is_xing($liu[1], $this->data['bazi'][6])
                || $this->is_liuchong($liu[1], $this->data['bazi'][6])
                || $this->is_liuhai($liu[1], $this->data['bazi'][6])
                || $this->is_xing($liu[1], $this->data['bazi'][8])
                || $this->is_liuchong($liu[1], $this->data['bazi'][8])
                || $this->is_liuhai($liu[1], $this->data['bazi'][8])
                || (
                    $this->data['dayun_now'] != null
                    &&
                    (
                        $this->is_xing($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuchong($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuhai($liu[1], $this->data['dayun_now'][1])
                    )
                )
            )
        )
        {
            $liu_shen_score[$liugan_shishen] += 0.5;
        }
        // 相穿呼应
        foreach ($ming_zhu as $k2 => $mzhu1)
        {
            $dizhi_benqi_shishen1 = $this->param['shishen'][$this->param['canggan'][$mzhu1[1]][0]][$rigan];
            foreach ($ming_zhu as $k3 => $mzhu2)
            {
                $dizhi_benqi_shishen2 = $this->param['shishen'][$this->param['canggan'][$mzhu2[1]][0]][$rigan];
                //	如本命出现两地支相穿，大运地支与流年地支分别是相穿的两地支
                //	如本命出现两地支相穿，流支为相穿地支之一
                if ($k3 > $k2 && $this->is_liuhai($mzhu1[1], $mzhu2[1]))
                {
                    if ($liu[1] == $mzhu1[1])
                    {
                        // 大运地支与流年地支分别是相穿的两地支，本命相穿两宫两支本气各+1破坏度
                        if ($this->data['dayun_now'] != null && $this->data['dayun_now'][1] == $mzhu2[1])
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                        // 流干的禄为相穿地支的另一个，本命相穿两宫两支本气各+1破坏度
                        if ($this->is_lushen($liu[0], $mzhu2[1]))
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                    } elseif ($liu[1] == $mzhu2[1])
                    {
                        // 大运地支与流年地支分别是相穿的两地支，本命相穿两宫两支本气各+1破坏度
                        if ($this->data['dayun_now'] != null && $this->data['dayun_now'][1] == $mzhu1[1])
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                        // 流干的禄为相穿地支的另一个，本命相穿两宫两支本气各+1破坏度
                        if ($this->is_lushen($liu[0], $mzhu1[1]))
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                    }
                }
            }
            //	如本命与大运地支相穿，流支为相穿地支之一，两穿地支及本命被穿宫位各+1破坏度
            if ($this->data['dayun_now'] != null &&
                $this->is_liuhai($this->data['dayun_now'][1], $mzhu1[1])
                && ($liu[1] == $this->data['dayun_now'][1] || $liu[1] == $mzhu1[1]))
            {
                $dayun_benqi_shishen = $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan];
                $liu_gong_score[$k2] += 1;
                $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                $liu_shen_score[$dayun_benqi_shishen] += 1;
            }
        }

        $this->data['shanggong'] = $liu_gong_score;
        $this->data['shangshen'] = $liu_shen_score;

        $this->data['or_shanggong'] = $gong_score;
        $this->data['or_shangshen'] = $shen_score;

        return;
    }

    /**
     * 获取天干五行得分
     * @param null $gan
     * @param null $zhi
     */
    private function getTianGanScore($gan = null, $zhi = null)
    {
        $base = 6;
        $config_wuxing = $this->param['wuxing'];
        $config_shishen = $this->param['shishen'];
        $config_canggan = $this->param['canggan'];

        $wuxing = $config_wuxing[$gan];
        $status = false;
        $change = 0;
        foreach ($config_canggan[$zhi] as $k1 => $cg1)
        {
            // 本气40
            if ($k1 === 0)
            {
                // 坐支本气为相同五行成分
                if ($wuxing == $config_wuxing[$cg1])
                {
                    $status = true;
                    $change += 5;
                }
                // 坐支本气正印
                if ($config_shishen[$cg1][$gan] == '正印')
                {
                    $status = true;
                    $change += 3;
                } // 坐支本气偏印
                elseif ($config_shishen[$cg1][$gan] == '偏印')
                {
                    $status = true;
                    $change += 1;
                } // 坐支本气七杀
                elseif ($config_shishen[$cg1][$gan] == '七杀')
                {
                    $status = true;
                    $change += -4;
                } // 坐支本气正官
                elseif ($config_shishen[$cg1][$gan] == '正官')
                {
                    $status = true;
                    $change += -2;
                } // 坐支本气正财
                elseif ($config_shishen[$cg1][$gan] == '正财')
                {
                    $status = true;
                    $change += -1;
                } // 坐支本气偏财
                elseif ($config_shishen[$cg1][$gan] == '偏财')
                {
                    $status = true;
                    $change += -1;
                }
            } else
            {
                // 坐支非本气为相同五行成分
                if ($wuxing == $config_wuxing[$cg1])
                {
                    $status = true;
                    $change += 3;
                }
            }
        }
        if ($status == true) $change += $base;

        $this->data['score'][$wuxing] += $change;
    }

    /**
     * 获取地支五行得分
     * @param null $zhi
     * @param bool $is_m 是否为月令
     */
    private function getDizhiScore($zhi = null, $is_m = false)
    {
        $metal = $wood = $water = $fire = $earth = 0;
        switch ($zhi)
        {
            case '子':
                $water += 10;
                break;
            case '丑':
                $earth += 6;
                $water += 2;
                $metal += 2;
                break;
            case '寅':
                $wood += 7;
                $fire += 2.5;
                $earth += 0.5;
                break;
            case '卯':
                $wood += 10;
                break;
            case '辰':
                $earth += 6;
                $wood += 2;
                $water += 2;
                break;
            case '巳':
                $fire += 7;
                $earth += 2.5;
                $metal += 0.5;
                break;
            case '午':
                $fire += 8;
                $earth += 4;
                break;
            case '未':
                $earth += 6;
                $wood += 2;
                $fire += 2;
                break;
            case '申':
                $metal += 7;
                $water += 2.5;
                $earth += 0.5;
                break;
            case '酉':
                $metal += 10;
                break;
            case '戌':
                $earth += 6;
                $fire += 2;
                $metal += 2;
                break;
            case '亥':
                $water += 7;
                $wood += 3;
                break;
        }

        if ($is_m)
        {
            $metal *= 2;
            $wood *= 2;
            $water *= 2;
            $fire *= 2;
            $earth *= 2;
        }
        $this->data['score']['金'] += $metal;
        $this->data['score']['木'] += $wood;
        $this->data['score']['水'] += $water;
        $this->data['score']['火'] += $fire;
        $this->data['score']['土'] += $earth;
    }

    /**
     * 五行生克得分
     * @param $score
     * @param null $rizhu
     */
    private function getShengkeScore($rizhu = null)
    {
        $config_wuxing = $this->param['wuxing'];

        $wuxing = $config_wuxing[$rizhu];

        switch ($wuxing)
        {
            case '金':
                $this->data['score']['金'] *= 1;// 同我
                $this->data['score']['土'] *= 0.5;// 生我
                $this->data['score']['火'] *= 1;// 克我
                $this->data['score']['木'] *= 0.6;// 我克
                $this->data['score']['水'] *= 0.3;// 我生
                break;
            case '水':
                $this->data['score']['水'] *= 1;
                $this->data['score']['金'] *= 0.5;
                $this->data['score']['土'] *= 1;
                $this->data['score']['火'] *= 0.6;
                $this->data['score']['木'] *= 0.3;
                break;
            case '木':
                $this->data['score']['木'] *= 1;
                $this->data['score']['水'] *= 0.5;
                $this->data['score']['金'] *= 1;
                $this->data['score']['土'] *= 0.6;
                $this->data['score']['火'] *= 0.3;
                break;
            case '火':
                $this->data['score']['火'] *= 1;
                $this->data['score']['木'] *= 0.5;
                $this->data['score']['水'] *= 1;
                $this->data['score']['金'] *= 0.6;
                $this->data['score']['土'] *= 0.3;
                break;
            case '土':
                $this->data['score']['土'] *= 1;
                $this->data['score']['火'] *= 0.5;
                $this->data['score']['木'] *= 1;
                $this->data['score']['水'] *= 0.6;
                $this->data['score']['金'] *= 0.3;
                break;
        }
    }

    /**
     * 获取五行百分比
     * @return mixed
     */
    public function getWuxingPercent()
    {
        $bazi = $this->data['bazi'];
        $this->getTianGanScore($bazi[1], $bazi[2]);
        $this->getTianGanScore($bazi[3], $bazi[4]);
        $this->getTianGanScore($bazi[5], $bazi[6]);
        $this->getTianGanScore($bazi[7], $bazi[8]);
        $this->getDizhiScore($bazi[2]);
        $this->getDizhiScore($bazi[4], true);
        $this->getDizhiScore($bazi[6]);
        $this->getDizhiScore($bazi[8]);
        $this->getShengkeScore($bazi[5]);

        $sum = array_sum($this->data['score']);

        foreach ($this->data['score'] as $k => $s)
        {
            $this->data['wuxing_perc'][$k] = round($s / $sum * 100, 0);
        }
        switch ($this->param['wuxing'][$bazi[5]])
        {
            case '金':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $this->data['wuxing_perc']['金'],
                    '印' => $this->data['wuxing_perc']['土'],
                    '官杀' => $this->data['wuxing_perc']['火'],
                    '财' => $this->data['wuxing_perc']['木'],
                    '食伤' => $this->data['wuxing_perc']['水'],
                ];
                break;
            case '水':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $this->data['wuxing_perc']['水'],
                    '印' => $this->data['wuxing_perc']['金'],
                    '官杀' => $this->data['wuxing_perc']['土'],
                    '财' => $this->data['wuxing_perc']['火'],
                    '食伤' => $this->data['wuxing_perc']['木'],
                ];
                break;
            case '木':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $this->data['wuxing_perc']['木'],
                    '印' => $this->data['wuxing_perc']['水'],
                    '官杀' => $this->data['wuxing_perc']['金'],
                    '财' => $this->data['wuxing_perc']['土'],
                    '食伤' => $this->data['wuxing_perc']['火'],
                ];
                break;
            case '火':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $this->data['wuxing_perc']['火'],
                    '印' => $this->data['wuxing_perc']['木'],
                    '官杀' => $this->data['wuxing_perc']['水'],
                    '财' => $this->data['wuxing_perc']['金'],
                    '食伤' => $this->data['wuxing_perc']['土'],
                ];
                break;
            default :
                $this->data['shishen_wuxing'] = [
                    '比劫' => $this->data['wuxing_perc']['土'],
                    '印' => $this->data['wuxing_perc']['火'],
                    '官杀' => $this->data['wuxing_perc']['木'],
                    '财' => $this->data['wuxing_perc']['水'],
                    '食伤' => $this->data['wuxing_perc']['金'],
                ];
                break;
        }
        return;
    }

    /**
     * 获取八字
     * @param $time
     * @param int $sunDeg
     * @param bool $getHour
     * @return array
     */
    public function getBazi($time, $sunDeg = 0, $getHour = false)
    {
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 十二地支
        $Earthly_Branches = $this->param['earthly_branches'];
        // 六十甲子
        $chinese_era = $this->param['chinese_era'];

        // 增加夏令时计算
        if ($this->option['recode']['is_summer'] == 1)
        {
            $time -= 3600;
        }

        // 若为真太阳时则
        if ($this->option['time_type'] == 1)
        {
            $longitude = ($this->option['recode']['long_deg'] + $this->option['recode']['long_min'] / 60) * $this->option['recode']['ew'];
            $this->data['birth_time'] = $time + ($longitude - $this->option['recode']['timezone'] * 15) * 4 * 60;
            $time = $this->data['birth_time'];
        }// 默认使用北京时间 把用户时间转换成北京时间
        else
        {
            $time += (8 - $this->option['recode']['timezone']) * 3600;
        }

        $year = date('Y', $time) * 1;
        $month = date('m', $time) * 1;
        $hour = intval(date('H', $time));

        $year_stem_branche = $this->getYearStemBranche($year);

        if ($month < 3 && $sunDeg < 315)
        {
            $year_stem_branche--;

            if ($year_stem_branche < 0) $year_stem_branche = 59;
        }

        $bazi_str = $chinese_era[$year_stem_branche];
        // 每15度一个节气   总共二十四节气  月令地支
        $month_branche = ["卯", "辰", "辰", "巳", "巳", "午", "午", "未", "未", "申", "申", "酉", "酉", "戌", "戌", "亥", "亥", "子", "子", "丑", "丑", "寅", "寅", "卯"];

        $temp = ["寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥", "子", "丑"];// 十二个月

        // $temp2 = ["丙","戊","庚","壬","甲","丙","戊","庚","壬","甲"];
        $temp2 = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0];

        $month_branche_num = intval(floor($sunDeg / 15));// 向下取整

        $month_branche_str = $month_branche[$month_branche_num];// 月令地支

        $year_stem = mb_substr($bazi_str, 0, 1, 'utf-8');

        $year_num = array_search($year_stem, $Heavenly_Stems);

        $start_num = $temp2[$year_num];

        $month_branche_num = array_search($month_branche_str, $temp);

        $newArr = array_merge($Heavenly_Stems, $Heavenly_Stems, $Heavenly_Stems);

        $s = [];

        for ($i = $start_num; $i < $start_num + 12; $i++) $s[] = $newArr[$i];

        $month_stem_branche = $s[$month_branche_num] . $month_branche_str;

        $time2 = 941990400;

        $time1 = strtotime(date('Y-m-d', $time));
        // 日辰初始默认使用24点
        $val = ($time1 - $time2) / 3600 / 24 % 60;

        // 日辰初始使用23点
        if ($getHour && $this->option['time_start'] == 23 && $hour == 23)
        {
            $val++;
            if ($val == 60) $val = 0;
        }

        $day_stem_branche = $val < 0 ? $val + 60 : $val;

        $bazi_str .= $month_stem_branche;

        $bazi_str .= $chinese_era[$day_stem_branche];

        $bazi = [
            1 => mb_substr($bazi_str, 0, 1, 'utf8'),
            2 => mb_substr($bazi_str, 1, 1, 'utf8'),
            3 => mb_substr($bazi_str, 2, 1, 'utf8'),
            4 => mb_substr($bazi_str, 3, 1, 'utf8'),
            5 => mb_substr($bazi_str, 4, 1, 'utf8'),
            6 => mb_substr($bazi_str, 5, 1, 'utf8'),
        ];

        if ($getHour)
        {
            // 二十四小时，十二个时辰  时辰地支
            $hour_branche = ["子", "丑", "丑", "寅", "寅", "卯", "卯", "辰", "辰", "巳", "巳", "午", "午", "未", "未", "申", "申", "酉", "酉", "戌", "戌", "亥", "亥", "子"];

            // $temp2 = ["甲","丙","戊","庚","壬","甲","丙","戊","庚","壬"];
            $temp2 = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8];

            $hour_branche_str = $hour_branche[$hour];// 时辰地支

            $day_stem_branche = mb_substr($chinese_era[$day_stem_branche], 0, 1, 'utf-8');

            $day_num = array_search($day_stem_branche, $Heavenly_Stems);

            // 若日辰初始为24点，且为晚子时（23～0点之间，包含0点），则晚子时的人往下推一天
            if ($this->option['time_start'] != 23 && $hour == 23)
            {
                $day_num++;
                // 溢出处理
                if ($day_num === 10)
                {
                    $day_num = 0;
                }
            }
            $start_num = $temp2[$day_num];

            $hour_branche_num = array_search($hour_branche_str, $Earthly_Branches);

            $newArr = array_merge($Heavenly_Stems, $Heavenly_Stems, $Heavenly_Stems);

            $s = [];
            for ($i = $start_num; $i < $start_num + 12; $i++)
            {
                $s[] = $newArr[$i];
            }

            $bazi_str .= $s[$hour_branche_num] . $hour_branche_str;

            $bazi[7] = mb_substr($bazi_str, 6, 1, 'utf8');
            $bazi[8] = mb_substr($bazi_str, 7, 1, 'utf8');
        }

        $this->data['bazi'] = $bazi;

        return $bazi;
    }

    /**
     * 获取年干支
     * @param null $year
     * @return int
     */
    public function getYearStemBranche($year = null)
    {
        return ($year - 4) % 60 < 0 ? ($year - 4) % 60 + 60 : ($year - 4) % 60;
    }

    /**
     * 获取起运时间
     */
    public function dayun()
    {
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 六十甲子
        $chinese_era = $this->param['chinese_era'];

        $num = array_search($this->data['bazi'][1], $Heavenly_Stems);

        $this->option['recode']['timezone'] = isset($this->option['recode']['timezone']) ? $this->option['recode']['timezone'] : 8;

        $this->option['recode']['is_summer'] = isset($this->option['recode']['is_summer']) ? $this->option['recode']['is_summer'] : 0;

        $this->option['recode']['type'];

        $birth_day_time_0 = $this->data['birth_time'] - ($this->option['recode']['timezone'] * 3600
                + 3600 * $this->option['recode']['is_summer']);

        // 阳男 || 阴女 六十甲子顺行 下一个节令时间 （节令黄经度数 为15°的奇数倍数）
        if (($num % 2 == 0 && $this->option['recode']['type'] == 1)
            || ($num % 2 == 1 && $this->option['recode']['type'] == 2))
        {
            $r = false;// 阳男 || 阴女  顺推

            $luck_time = (new Solarterms())->getTremTime(['time' => $birth_day_time_0, 'sort' => 'asc']);

        } // 阴男 || 阳女 六十甲子逆行  上一个节令时间 （节令黄经度数 为15°的奇数倍数）
        else
        {
            $r = true;// 阴男 || 阳女 逆推

            $luck_time = (new Solarterms())->getTremTime(['time' => $birth_day_time_0, 'sort' => 'desc']);
        }

        $diff_year = abs($birth_day_time_0 - $luck_time) / 3600 / 24 / 3;

        $st_time = $this->data['birth_time'] + $diff_year * 365 * 24 * 3600;

        // 大运
        $yuezhu = $this->data['bazi'][3] . $this->data['bazi'][4];
        $dayun_bazi_array = array_merge($chinese_era, $chinese_era, $chinese_era);

        if ($r == true)
        {
            $all = array_reverse($dayun_bazi_array);
            $this->data['dayun'] = array_slice($all, array_search($yuezhu, $all) + 1, 60);
        } else
        {
            $this->data['dayun'] = array_slice($dayun_bazi_array, array_search($yuezhu, $dayun_bazi_array) + 1, 60);
        }

        $this->data['st_time'] = $st_time;
        return;
    }

    /**
     * 获取八字十神关系
     * @return array
     */
    public function getShishen()
    {
        $config_shishen = $this->param['shishen'];
        $config_canggan = $this->param['canggan'];
        $shishen = [];
        for ($i = 1; $i < 9; $i++)
        {
            if ($i == 5) continue;
            $rigan = $this->data['bazi'][5];
            $other = $this->data['bazi'][$i];
//            $loc = ceil($i / 2);
            // 干
            if ($i % 2 == 1)
            {
                $shishen['gan'][$i] = [
                    'a' => $rigan,
                    'b' => $other,
                    'relation' => $config_shishen[$other][$rigan],
                    'loc' => $i,
                ];
            } // 藏干
            else
            {
                foreach ($config_canggan[$other] as $k => $g)
                {
                    $benqi = $k === 0 ? true : false;
                    $shishen['cang'][$i][] = [
                        'a' => $rigan,
                        'b' => $other,
                        'relation' => $config_shishen[$g][$rigan],
                        'loc' => $i,
                        'benqi' => $benqi
                    ];
                }
            }
        }
        return $shishen;
    }

    /**
     * 获取当前八字神煞关系
     * @return array
     */
    public function getShensha()
    {
        $huagai = $this->huagai();
        $taohua = $this->taohua();
        $yima = $this->yima();
        $wangshen = $this->wangshen();
        $jiesha = $this->jiesha();
        $jiangxing = $this->jiangxing();
        $zaisha = $this->zaisha();
        $tianyiguiren = $this->tianyiguiren();
        $tiandeguiren = $this->tiandeguiren();
        $wenchangguiren = $this->wenchangguiren();
        $yuedeguiren = $this->yuedeguiren();
        $jinyu = $this->jinyu();
        $hongyansha = $this->hongyansha();
        $guchen = $this->guchen();
        $guaxiu = $this->guaxiu();
        $lushen = $this->lushen();
        $yangren = $this->yangren();
        $jinshen = $this->jinshen();
        $shensha = array_merge($huagai, $taohua, $yima, $wangshen, $jiesha, $jiangxing, $zaisha, $tianyiguiren, $tiandeguiren, $wenchangguiren, $yuedeguiren, $jinyu, $hongyansha, $guchen, $guaxiu, $lushen, $yangren, $jinshen);

        return $shensha;

    }

    /**
     * 华盖
     * @return array
     */
    private function huagai()
    {
        $ret = [];
        $name = '华盖';
        if ($this->is_huagai($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 桃花
     * @return array
     */
    private function taohua()
    {
        $ret = [];
        $name = '桃花';
        if ($this->is_taohua($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 驿马
     * @return array
     */
    private function yima()
    {
        $ret = [];
        $name = '驿马';
        if ($this->is_yima($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_yima($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_yima($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_yima($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_yima($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_yima($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 亡神
     * @return array
     */
    private function wangshen()
    {
        $ret = [];
        $name = '亡神';
        if ($this->is_wangshen($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 劫煞
     * @return array
     */
    private function jiesha()
    {
        $ret = [];
        $name = '劫煞';
        if ($this->is_jiesha($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 将星
     * @return array
     */
    private function jiangxing()
    {
        $ret = [];
        $name = '将星';
        if ($this->is_jiangxing($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 灾煞
     * @return array
     */
    private function zaisha()
    {
        $ret = [];
        $name = '灾煞';
        if ($this->is_zaisha($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 天乙贵人
     * @return array
     */
    private function tianyiguiren()
    {
        $ret = [];
        $name = '天乙贵人';
        if ($this->is_tianyiguiren($this->data['bazi'][1], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][1] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][1], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][1] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '月支',
                'location_num' => 2,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 天德贵人
     * @return array
     */
    private function tiandeguiren()
    {
        $ret = [];
        $name = '天德贵人';
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][5]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][5],
                'location_cn' => '日干',
                'location_num' => 5,
            ];
        }
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][7]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][7],
                'location_cn' => '时干',
                'location_num' => 7,
            ];
        }
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 文昌贵人
     * @return array
     */
    private function wenchangguiren()
    {
        $ret = [];
        $name = '文昌贵人';
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 月德贵人
     * @return array
     */
    private function yuedeguiren()
    {
        $ret = [];
        $name = '月德贵人';
        if ($this->is_yuedeguiren($this->data['bazi'][4], $this->data['bazi'][5]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][5],
                'location_cn' => '日干',
                'location_num' => 5,
            ];
        }
        if ($this->is_yuedeguiren($this->data['bazi'][4], $this->data['bazi'][7]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][7],
                'location_cn' => '时干',
                'location_num' => 7,
            ];
        }
        return $ret;
    }

    /**
     * 金舆
     * @return array
     */
    private function jinyu()
    {
        $ret = [];
        $name = '金舆';
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 红艳煞
     * @return array
     */
    private function hongyansha()
    {
        $ret = [];
        $name = '红艳煞';
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 孤辰
     * @return array
     */
    private function guchen()
    {
        $ret = [];
        $name = '孤辰';
        if ($this->is_guchen($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_guchen($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 寡宿
     * @return array
     */
    private function guaxiu()
    {
        $ret = [];
        $name = '寡宿';
        if ($this->is_guaxiu($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_guaxiu($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 禄神
     * @return array
     */
    private function lushen()
    {
        $ret = [];
        $name = '禄神';
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 羊刃
     * @return array
     */
    private function yangren()
    {
        $ret = [];
        $name = '羊刃';
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 金神
     * @return array
     */
    private function jinshen()
    {
        $ret = [];
        $name = '金神';
        if ($this->is_jinshen($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jinshen($this->data['bazi'][7], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][7] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 检查是否为华盖
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_huagai($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['戌', '未', '辰', '丑'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为桃花
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_taohua($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['卯', '子', '酉', '午'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为驿马
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_yima($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['申', '巳', '寅', '亥'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为亡神
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_wangshen($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['巳', '寅', '亥', '申'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为劫煞
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_jiesha($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['亥', '申', '巳', '寅'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为将星
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_jiangxing($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['午', '卯', '子', '酉'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为灾煞
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_zaisha($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['子', '酉', '午', '卯'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为天乙贵人
     * @param null $gan 年干   /   日干
     * @param null $zhi 日时支  /  四地支
     * @return bool
     */
    private function is_tianyiguiren($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['天乙贵人'];
        if (isset($lx[$gan]) && in_array($zhi, $lx[$gan])) return true;
        else return false;
    }

    /**
     * 检查是否为天德贵人
     * @param null $mzhi
     * @param null $zhi 日时干支
     * @return bool
     */
    private function is_tiandeguiren($mzhi = null, $zhi = null)
    {
        $lx = $this->param['shensha']['天德贵人'];
        if (isset($lx[$mzhi]) && $lx[$mzhi] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为文昌贵人
     * @param null $gan 日干
     * @param null $zhi 地支
     * @return bool
     */
    private function is_wenchangguiren($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['文昌贵人'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为月德贵人
     * @param null $yzhi 月支
     * @param null $zhi 日时干支  壬丙庚甲
     * @return bool
     */
    private function is_yuedeguiren($yzhi = null, $zhi = null)
    {
        $lx = $this->param['shensha']['月德贵人'];
        if (isset($lx[$yzhi]) && $lx[$yzhi] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为金舆
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_jinyu($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['金舆'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为红艳煞
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_hongyansha($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['红艳煞'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为孤辰
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_guchen($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['孤辰'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为寡宿
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_guaxiu($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['寡宿'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为禄神
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_lushen($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['禄神'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为羊刃
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_yangren($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['羊刃'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为金神
     * $gan $zhi 为日干支  ||  时干支   组合
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_jinshen($gan = null, $zhi = null)
    {
        $ganzhi = $gan . $zhi;
        $lx = $this->param['shensha']['金神'];
        foreach ($lx as $x) if ($x == $ganzhi) return true;
        return false;
    }

    /**
     * 天干五合
     * 甲己相合为土，乙庚相合为金，丙辛相合为水，丁壬相合为木，戊癸相合为火。
     * @param null $gan1
     * @param null $gan2
     * @return bool
     */
    public function is_wuhe($gan1 = null, $gan2 = null)
    {
        if (($gan1 == '甲' && $gan2 == '己') || ($gan1 == '己' && $gan2 == '甲'))
        {
            return true;
        } elseif (($gan1 == '乙' && $gan2 == '庚') || ($gan1 == '庚' && $gan2 == '乙'))
        {
            return true;
        } elseif (($gan1 == '丙' && $gan2 == '辛') || ($gan1 == '辛' && $gan2 == '丙'))
        {
            return true;
        } elseif (($gan1 == '丁' && $gan2 == '壬') || ($gan1 == '壬' && $gan2 == '丁'))
        {
            return true;
        } elseif (($gan1 == '戊' && $gan2 == '癸') || ($gan1 == '癸' && $gan2 == '戊'))
        {
            return true;
        }
        return false;
    }

    /**
     * 检查地支是否六合
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liuhe($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $liuhe = ['子丑', '寅亥', '卯戌', '辰酉', '巳申', '午未'];
        foreach ($liuhe as $lh)
        {
            if ($zhi1 . $zhi2 == $lh || $zhi2 . $zhi1 == $lh)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否六冲
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liuchong($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $liuchong = ['子午', '丑未', '寅申', '卯酉', '辰戌', '巳亥'];
        foreach ($liuchong as $lc)
        {
            if (is_array($zhi2) && !empty($zhi2))
            {
                foreach ($zhi2 as $z2)
                {
                    if ($zhi1 . $z2 == $lc || $z2 . $zhi1 == $lc)
                    {
                        return true;
                    }
                }
            } else
            {
                if ($zhi1 . $zhi2 == $lc || $zhi2 . $zhi1 == $lc)
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 检查地支是否六害
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liuhai($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $liuhai = ['子未', '丑午', '寅巳', '卯辰', '申亥', '酉戌'];
        foreach ($liuhai as $lh)
        {
            if (is_array($zhi2) && !empty($zhi2))
            {
                foreach ($zhi2 as $z2)
                {
                    if ($zhi1 . $z2 == $lh || $z2 . $zhi1 == $lh)
                    {
                        return true;
                    }
                }
            } else
            {
                if ($zhi1 . $zhi2 == $lh || $zhi2 . $zhi1 == $lh)
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 检查地支是否拱
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    private function is_gong($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $gong = [['申', '子', '辰'], ['寅', '午', '戌'], ['亥', '卯', '未'], ['巳', '酉', '丑']];// 水 火 木 金
        foreach ($gong as $g)
        {
            if (in_array($zhi1, $g) && in_array($zhi2, $g))
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否三会
     * @param null $zhi1
     * @param null $zhi2
     * @param null $zhi3
     * @return bool
     */
    private function is_sanhui($zhi1 = null, $zhi2 = null, $zhi3 = null)
    {
        if (!$zhi1 || !$zhi2 || !$zhi3 || $zhi1 == $zhi2 || $zhi1 == $zhi3 || $zhi2 == $zhi3) return false;
        $sanhui = ['亥子丑', '寅卯辰', '巳午未', '申酉戌'];// 水 木 火 金
        foreach ($sanhui as $sh)
        {
            if (
                $zhi1 . $zhi2 . $zhi3 == $sh
                || $zhi1 . $zhi3 . $zhi2 == $sh
                || $zhi2 . $zhi1 . $zhi3 == $sh
                || $zhi2 . $zhi3 . $zhi1 == $sh
                || $zhi3 . $zhi1 . $zhi2 == $sh
                || $zhi3 . $zhi2 . $zhi1 == $sh
            )
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否三刑
     * @param null $zhi1
     * @param null $zhi2
     * @param null $zhi3
     * @return bool
     */
    private function is_sanxing($zhi1 = null, $zhi2 = null, $zhi3 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2 || $zhi1 == $zhi3 || $zhi2 == $zhi3) return false;
        $sanxing = ['寅巳申', '丑戌未', '子卯'];// 水 木 火 金
        foreach ($sanxing as $sx)
        {
            if (
                $zhi1 . $zhi2 . $zhi3 == $sx
                || $zhi1 . $zhi3 . $zhi2 == $sx
                || $zhi2 . $zhi1 . $zhi3 == $sx
                || $zhi2 . $zhi3 . $zhi1 == $sx
                || $zhi3 . $zhi1 . $zhi2 == $sx
                || $zhi3 . $zhi2 . $zhi1 == $sx
            )
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否刑
     * 丑未为六冲  寅申为六冲  巳申为六合 排除这三种
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_xing($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2 || (in_array($zhi1, ['丑', '未']) && in_array($zhi2, ['丑', '未']))) return false;
        $xing = [['寅', '巳'], ['丑', '戌', '未']];
        foreach ($xing as $x)
        {
            if (in_array($zhi1, $x) && in_array($zhi2, $x))
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否自刑
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    private function is_zixing($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 != $zhi2) return false;
        $zixing = ['辰', '午', '酉', '亥'];
        foreach ($zixing as $zx)
        {
            if ($zhi1 == $zx)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 盖头
     * 天干克地支（同柱）
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return bool
     */
    private function is_gaitou($gan = null, $zhi = null)
    {
        if (!$gan || !$zhi) return false;

        $gaitou = ['甲辰', '甲戌', '乙丑', '乙未', '丙申', '丁酉', '戊亥', '己子', '庚寅', '辛卯', '壬巳', '癸午'];

        if (in_array($gan . $zhi, $gaitou))
        {
            return true;
        }
        return false;
    }

    /**
     * 截脚
     * 地支克天干（同柱）
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return bool
     */
    private function is_jiejiao($gan = null, $zhi = null)
    {
        if (!$gan || !$zhi || mb_strlen($gan) != 1 || mb_strlen($zhi) != 1) return false;

        $jiejiao = ['甲申', '乙酉', '丙亥', '丁子', '戊寅', '己卯', '庚巳', '辛午', '壬辰', '壬戌', '癸丑', '癸未'];

        if (in_array($gan . $zhi, $jiejiao))
        {
            return true;
        }
        return false;
    }

    /**
     * 纳音关系
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return string
     */
    private function getNayin($gan = null, $zhi = null)
    {
        $nayin = '';
        switch ($gan . $zhi)
        {
            case '甲子':
            case '乙丑':
                $nayin = '海中金';
                break;
            case '丙寅':
            case '丁卯':
                $nayin = '炉中火';
                break;
            case '戊辰':
            case '己巳':
                $nayin = '大林木';
                break;
            case '庚午':
            case '辛未':
                $nayin = '路旁土';
                break;
            case '壬申':
            case '癸酉':
                $nayin = '剑锋金';
                break;
            case '甲戌':
            case '乙亥':
                $nayin = '山头火';
                break;
            case '丙子':
            case '丁丑':
                $nayin = '涧下水';
                break;
            case '戊寅':
            case '己卯':
                $nayin = '城头土';
                break;
            case '庚辰':
            case '辛巳':
                $nayin = '白蜡金';
                break;
            case '壬午':
            case '癸未':
                $nayin = '杨柳木';
                break;
            case '甲申':
            case '乙酉':
                $nayin = '井泉水';
                break;
            case '丙戌':
            case '丁亥':
                $nayin = '屋上土';
                break;
            case '戊子':
            case '己丑':
                $nayin = '霹雳火';
                break;
            case '庚寅':
            case '辛卯':
                $nayin = '松柏木';
                break;
            case '壬辰':
            case '癸巳':
                $nayin = '长流水';
                break;
            case '甲午':
            case '乙未':
                $nayin = '砂中金';
                break;
            case '丙申':
            case '丁酉':
                $nayin = '山下火';
                break;
            case '戊戌':
            case '己亥':
                $nayin = '平地木';
                break;
            case '庚子':
            case '辛丑':
                $nayin = '壁上土';
                break;
            case '壬寅':
            case '癸卯':
                $nayin = '金箔金';
                break;
            case '甲辰':
            case '乙巳':
                $nayin = '覆灯火';
                break;
            case '丙午':
            case '丁未':
                $nayin = '天河水';
                break;
            case '戊申':
            case '己酉':
                $nayin = '大驿土';
                break;
            case '庚戌':
            case '辛亥':
                $nayin = '钗钏金';
                break;
            case '壬子':
            case '癸丑':
                $nayin = '桑柘木';
                break;
            case '甲寅':
            case '乙卯':
                $nayin = '大溪水';
                break;
            case '丙辰':
            case '丁巳':
                $nayin = '砂中土';
                break;
            case '戊午':
            case '己未':
                $nayin = '天上火';
                break;
            case '庚申':
            case '辛酉':
                $nayin = '石榴木';
                break;
            case '壬戌':
            case '癸亥':
                $nayin = '大海水';
                break;
            default:
                break;
        }
        return $nayin;
    }

    /**
     * 空亡
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return string
     */
    private function getKongwang($gan = null, $zhi = null)
    {
        $kongwang = '';
        $ganzhi = $gan . $zhi;
        if (in_array($ganzhi, ['甲子', '乙丑', '丙寅', '丁卯', '戊辰', '己巳', '庚午', '辛未', '壬申', '癸酉']))
        {
            $kongwang = '戌亥';
        } elseif (in_array($ganzhi, ['甲戌', '乙亥', '丙子', '丁丑', '戊寅', '己卯', '庚辰', '辛巳', '壬午', '癸未']))
        {
            $kongwang = '申酉';
        } elseif (in_array($ganzhi, ['甲申', '乙酉', '丙戌', '丁亥', '戊子', '己丑', '庚寅', '辛卯', '壬辰', '癸巳']))
        {
            $kongwang = '午未';
        } elseif (in_array($ganzhi, ['甲午', '乙未', '丙申', '丁酉', '戊戌', '己亥', '庚子', '辛丑', '壬寅', '癸卯']))
        {
            $kongwang = '辰巳';
        } elseif (in_array($ganzhi, ['甲辰', '乙巳', '丙午', '丁未', '戊申', '己酉', '庚戌', '辛亥', '壬子', '癸丑']))
        {
            $kongwang = '寅卯';
        } elseif (in_array($ganzhi, ['甲寅', '乙卯', '丙辰', '丁巳', '戊午', '己未', '庚申', '辛酉', '壬戌', '癸亥']))
        {
            $kongwang = '子丑';
        }
        return $kongwang;
    }

    /**
     * 十神关系  转化为单字显示
     * @param string $relation
     * @return string
     */
    private function shishenToEasy($relation = '')
    {
        switch ($relation)
        {
            case '正财':
                return '财';
            case '偏财':
                return '才';
            case '正印':
                return '印';
            case '偏印':
                return '枭';
            case '食神':
                return '食';
            case '伤官':
                return '伤';
            case '比肩':
                return '比';
            case '劫财':
                return '劫';
            case '七杀':
                return '杀';
            case '正官':
                return '官';
            default:
                return '';
        }
    }

    /**
     * 判断两天干 十神关系
     * @param null $gan1 天干1
     * @param null $gan2 天干2 一般为日干
     * @param null $rela 关系  印 官杀 财 比劫 食伤
     * @return bool
     */
    private function is_ygs($gan1 = null, $gan2 = null, $rela = null)
    {
        if (!$gan1 || !$gan2 || !$rela) return false;

        $temp = $this->param['shishen'][$gan1][$gan2];

        if ($rela == '印' && ($temp == '正印' || $temp == '偏印'))
        {
            return true;
        } elseif ($rela == '官杀' && ($temp == '七杀' || $temp == '正官'))
        {
            return true;
        } elseif ($rela == '财' && ($temp == '正财' || $temp == '偏财'))
        {
            return true;
        } elseif ($rela == '比劫' && ($temp == '比肩' || $temp == '劫财'))
        {
            return true;
        } elseif ($rela == '食伤' && ($temp == '食神' || $temp == '伤官'))
        {
            return true;
        }
        return false;
    }

    /**
     * 身旺/身弱
     * 本命或大运地支 有日干本气比劫
     * 本命或大运地支 有本气正偏印两个以上，且日干有根
     * 本命或大运天干 有比劫印共两个或以上，且日干有根
     * 非旺则弱
     */
    private function is_shenwang()
    {
        // 日干
        $rigan = $this->data['bazi'][5];
        // 地支 印数量
        $yin_num = 0;
        // 天干 比劫印数量
        $bijieyin_num = 0;
        // 日干是否有根 (如果某地支含有与某天干相同的五行，就是该天干的根)
        $is_rigan_gen = false;
        // 日干五行
        $rigan_wuxing = $this->param['wuxing'][$rigan];

        foreach ([2, 4, 6, 8] as $i)
        {
            // 本命地支本气 为日干的比劫
            if ($this->is_ygs($this->param['canggan'][$this->data['bazi'][$i]][0], $this->data['bazi'][5], '比劫'))
            {
                return true;
            }
            // 本命地支藏干
            $gans = $this->param['canggan'][$this->data['bazi'][$i]];

            $temp = $this->param['shishen'][$gans[0]][$rigan];

            if (in_array($temp, ['比肩', '劫财']))
            {
                return true;
            } elseif (in_array($temp, ['正印', '偏印']))
            {
                $yin_num++;
            }
            foreach ($gans as $gan)
            {
                if ($is_rigan_gen === false && $this->param['wuxing'][$gan] == $rigan_wuxing)
                {
                    $is_rigan_gen = true;
                }
            }
        }
        if ($this->data['dayun_now'] != null)
        {
            // 大运地支本气
            $dayun_benqi = $this->param['canggan'][$this->data['dayun_now'][1]][0];
            // 与日干的关系
            $temp = $this->param['shishen'][$dayun_benqi][$rigan];

            if (in_array($temp, ['比肩', '劫财']))
            {
                return true;
            } elseif (in_array($temp, ['正印', '偏印']))
            {
                $yin_num++;
            }
        }

        if ($is_rigan_gen === true)
        {
            if ($yin_num >= 2)
            {
                return true;
            }
            foreach ([1, 3, 7] as $j)
            {
                $temp = $this->param['shishen'][$this->data['bazi'][$j]][$rigan];
                if (in_array($temp, ['比肩', '劫财', '正印', '偏印']))
                {
                    $bijieyin_num++;
                }
            }
            if ($this->data['dayun_now'] != null)
            {
                // 大运天干
                $dayun_tiangan = $this->data['dayun_now'][0];
                // 与日干的关系
                $temp = $this->param['shishen'][$dayun_tiangan][$rigan];

                if (in_array($temp, ['比肩', '劫财', '正印', '偏印']))
                {
                    $bijieyin_num++;
                }
            }
            if ($bijieyin_num >= 2)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 流年主神
     * 流干的十神定为主神
     * 若流干为比肩
     *   流支十神定为主神
     *   流支如与命运某支合拱，合拱的十神定为主神
     */
    private function getZhuShen()
    {
        $result = [];

        $rigan = $this->data['bazi'][5];

        $liu = $this->data['liunian_now'];

        $temp = $this->param['shishen'][$liu[0]][$rigan];

        if ($temp == '比肩')
        {
            $liuzhi_benqi = $this->param['canggan'][$liu[1]][0];

            $temp = $this->param['shishen'][$liuzhi_benqi][$rigan];
            // 本命+大运 地支
            $mingyun_zhis = [
                $this->data['bazi'][2],
                $this->data['bazi'][4],
                $this->data['bazi'][6],
                $this->data['bazi'][8],
            ];
            if ($this->data['dayun_now'] != null) $mingyun_zhis[] = $this->data['dayun_now'][1];
            $zhi_shishen = [];
            foreach ($mingyun_zhis as $myz)
            {
                if ($this->is_liuhe($liu[1], $myz) || $this->is_gong($liu[1], $myz))
                {
                    $zhi_benqi = $this->param['canggan'][$myz][0];

                    $liuzhi_shishen = $this->param['shishen'][$zhi_benqi][$rigan];

                    if ($liuzhi_shishen != '比肩') $zhi_shishen[] = $liuzhi_shishen;
                }
            }

            if (!empty($zhi_shishen))
            {
                $result = $zhi_shishen;
            } else
            {
                $result[] = $temp;
            }
        } else
        {
            $result[] = $temp;
        }

        return $result;
    }

    /**
     * 干支不协
     * 流年与命运某柱干合支穿或干合支刑
     */
    private function is_ganzhibuxie()
    {
        $liu = $this->data['liunian_now'];

        $zhus = [
            [$this->data['bazi'][1], $this->data['bazi'][2]],
            [$this->data['bazi'][3], $this->data['bazi'][4]],
            [$this->data['bazi'][5], $this->data['bazi'][6]],
            [$this->data['bazi'][7], $this->data['bazi'][8]],
        ];
        if ($this->data['dayun_now'] != null)
        {
            $zhus[] = $this->data['dayun_now'];
        }
        foreach ($zhus as $zhu)
        {
            if ($this->is_wuhe($zhu[0], $liu[0]))
            {
                if ($this->is_xing($zhu[1], $liu[1]) || $this->is_liuhai($zhu[1], $liu[1]))
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 安静
     * 流支与命运支没有刑冲合穿拱
     * 刑、六冲、六合、拱、六害
     */
    private function is_anjing()
    {
        $liu = $this->data['liunian_now'];

        $zhis = [
            $this->data['bazi'][2],
            $this->data['bazi'][4],
            $this->data['bazi'][6],
            $this->data['bazi'][8],
        ];

        if ($this->data['dayun_now'] != null)
        {
            $zhis[] = $this->data['dayun_now'][1];
        }
        foreach ($zhis as $zhi)
        {
            if ($this->is_xing($zhi, $liu[1])
                || $this->is_liuchong($zhi, $liu[1])
                || $this->is_liuhe($zhi, $liu[1])
                || $this->is_gong($zhi, $liu[1])
                || $this->is_liuhai($zhi, $liu[1]))
            {
                return false;
            }
        }
        return true;
    }

    /**
     * 双冲
     * 流年与命运某柱形成天克地冲
     * 天干同性相克 偏财或七杀
     * @param array $zhu1 流年
     * @param array $zhu2 本命或大运干支 [[],[]]
     * @return bool
     */
    private function is_shuangchong($zhu1 = [], $zhu2 = [])
    {
        if (empty($zhu1) || empty($zhu2))
        {
            return false;
        }
        foreach ($zhu2 as $zhu)
        {
            if (in_array($this->param['shishen'][$zhu1[0]][$zhu[0]], ['偏财', '七杀']))
            {
                if ($this->is_liuchong($zhu[1], $zhu1[1]))
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 八字格局
     * @return string
     */
    private function getStructure()
    {
        $bazi = $this->data['bazi'];
        /**
         * 八字格局前缀
         * 1.通变
         * 2.杂气
         */
        $str = '';
        /**
         * 八字格局
         */
        $geju = '';
        $yue_benqi = $this->param['canggan'][$bazi[4]][0];

        $temp = [];

        $canggan = $this->param['canggan'][$bazi[4]];// 月令藏干

        // 检测月令透干
        foreach ($canggan as $cg)
        {
            // 是否透出年干
            if ($this->param['wuxing'][$cg] == $this->param['wuxing'][$bazi[1]])
            {
                if (!isset($temp[$this->param['wuxing'][$bazi[1]]][$this->param['wuxing_yinyang'][$bazi[1]]]))
                    $temp[$this->param['wuxing'][$bazi[1]]][$this->param['wuxing_yinyang'][$bazi[1]]] = 0;
                $temp[$this->param['wuxing'][$bazi[1]]][$this->param['wuxing_yinyang'][$bazi[1]]]++;
                $temp[$this->param['wuxing'][$bazi[1]]]['zhi'] = $cg;
                $temp[$this->param['wuxing'][$bazi[1]]]['gan'][] = $bazi[1];
                $temp[$this->param['wuxing'][$bazi[1]]]['num'][] = 1;
            }
            // 是否透出月干
            if ($this->param['wuxing'][$cg] == $this->param['wuxing'][$bazi[3]])
            {
                if (!isset($temp[$this->param['wuxing'][$bazi[3]]][$this->param['wuxing_yinyang'][$bazi[3]]]))
                    $temp[$this->param['wuxing'][$bazi[3]]][$this->param['wuxing_yinyang'][$bazi[3]]] = 0;
                $temp[$this->param['wuxing'][$bazi[3]]][$this->param['wuxing_yinyang'][$bazi[3]]]++;
                $temp[$this->param['wuxing'][$bazi[3]]]['zhi'] = $cg;
                $temp[$this->param['wuxing'][$bazi[3]]]['gan'][] = $bazi[3];
                $temp[$this->param['wuxing'][$bazi[3]]]['num'][] = 3;
            }
            // 是否透出时干
            if ($this->param['wuxing'][$cg] == $this->param['wuxing'][$bazi[7]])
            {
                if (!isset($temp[$this->param['wuxing'][$bazi[7]]][$this->param['wuxing_yinyang'][$bazi[7]]]))
                    $temp[$this->param['wuxing'][$bazi[7]]][$this->param['wuxing_yinyang'][$bazi[7]]] = 0;
                $temp[$this->param['wuxing'][$bazi[7]]][$this->param['wuxing_yinyang'][$bazi[7]]]++;
                $temp[$this->param['wuxing'][$bazi[7]]]['zhi'] = $cg;
                $temp[$this->param['wuxing'][$bazi[7]]]['gan'][] = $bazi[7];
                $temp[$this->param['wuxing'][$bazi[7]]]['num'][] = 7;
            }
        }
        // 月令为辰戌丑未
        if (in_array($bazi[4], ['辰', '戌', '丑', '未']))
        {
            $str .= '杂气';
            // 若月令只透一种五行，且该五行非比肩劫财，则可依此确定格局；
            if (count($temp) == 1)
            {
                foreach ($temp as $w => $t)
                {
                    // 该五行非比肩劫财，则可依此确定格局；
                    if ($this->param['wuxing'][$t['zhi']] != $this->param['wuxing'][$bazi['5']])
                    {
                        $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . "格";
                    }
                    // 若月令透出一种五行但有阴阳两干，
                    if (isset($t[0]) && isset($t[1]))
                    {
                        // 正官七杀同在则取七杀格，正财偏财同现则以月令所藏为准，正印偏印同现也以月令所藏为准，食伤同现则取伤官格；
                        $_shishen = [];
                        foreach ($t['gan'] as $gan)
                        {
                            $_shishen[] = $this->param['shishen'][$gan][$bazi[5]];
                        }
                        if ($_shishen[0] == '七杀' || $_shishen[1] == '正官')
                        {
                            $geju = '七杀格';
                        } elseif ($_shishen[0] == '正财' || $_shishen[1] == '偏财')
                        {
                            $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . '格';
                        } elseif ($_shishen[0] == '正印' || $_shishen[1] == '偏印')
                        {
                            $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . '格';
                        } elseif ($_shishen[0] == '食神' || $_shishen[1] == '伤官')
                        {
                            $geju = '伤官格';
                        }
                        // 若月令只透一种五行且该五行为比肩劫财，则再观察其 所透是否为月令本气土，
                        // 若不是，则以月令本气定格，若是，则暂不取格。
                        if ($this->param['wuxing'][$t['zhi']] == $this->param['wuxing'][$bazi['5']] && $t['zhi'] != $yue_benqi)
                        {
                            $geju = $this->param['shishen'][$yue_benqi][$bazi[5]] . '格';
                        }
                    }
                    // 若月令透出五行阴阳与月令所藏不同，则以透出者为准；
                    if ((!isset($t[0]) || !isset($t[1])) && $w == $this->param['wuxing'][$t['zhi']] && $t['zhi'] != $t['gan'][0])
                    {
                        $geju = $this->param['shishen'][$t['gan'][0]][$bazi[5]] . '格';
                    }
                    if ($geju) break;

                }
            } // 若月令透出两种或三种五行，则分别视其为何种十神再分主次，优先取官杀、其次为财、再次为印星，最次为食伤；
            elseif (count($temp) > 1)
            {
                $tougan_shishen = [];
                foreach ($temp as $w => $t)
                {
                    // 遍历所透天干
                    foreach ($t['gan'] as $t_gan)
                    {

                        $ts_shishen = $this->param['shishen'][$t_gan][$bazi[5]];// 此处为所透天干，不是藏干

                        if (in_array($ts_shishen, ['正官', '七杀', '正财', '偏财', '正印', '偏印', '食神', '伤官']))
                        {
                            $tougan_shishen[] = $ts_shishen;
                        }
                    }
                }

                // 正官七杀同在则取七杀格，正财偏财同现则以月令所藏为准，正印偏印同现也以月令所藏为准，食伤同现则取伤官格；
                if (in_array('七杀', $tougan_shishen)) $geju = '七杀格';
                elseif (in_array('正官', $tougan_shishen)) $geju = '正官格';
                elseif (in_array('正财', $tougan_shishen) && in_array('偏财', $tougan_shishen))
                {
                    foreach ($canggan as $cg)
                    {
                        if ($this->param['shishen'][$cg][$bazi[5]] == '正财') $geju = '正财格';
                        if ($this->param['shishen'][$cg][$bazi[5]] == '偏财') $geju = '偏财格';
                    }
                } elseif (in_array('正财', $tougan_shishen)) $geju = '正财格';
                elseif (in_array('偏财', $tougan_shishen)) $geju = '偏财格';
                elseif (in_array('正印', $tougan_shishen) && in_array('偏印', $tougan_shishen))
                {
                    foreach ($canggan as $cg)
                    {
                        if ($this->param['shishen'][$cg][$bazi[5]] == '正印') $geju = '正印格';
                        if ($this->param['shishen'][$cg][$bazi[5]] == '偏印') $geju = '偏印格';
                    }
                } elseif (in_array('正印', $tougan_shishen)) $geju = '正印格';
                elseif (in_array('偏印', $tougan_shishen)) $geju = '偏印格';
                elseif (in_array('伤官', $tougan_shishen)) $geju = '伤官格';
                elseif (in_array('食神', $tougan_shishen)) $geju = '食神格';

            }

        } // 月令非辰戌丑未
        elseif (!in_array($bazi[4], ['辰', '戌', '丑', '未']))
        {
            $yue_shishen = $this->param['shishen'][$yue_benqi][$this->data['bazi'][5]];
            if ($yue_shishen == '比肩')
            {
                $geju = '建禄格';
            } elseif ($yue_shishen == '劫财')
            {
                if (in_array($this->data['bazi'][5], ['甲', '丙', '戊', '庚', '壬'])) $geju = '月刃格';

                else $geju = '月劫格';

            }

            if ($geju == '')
            {
                // 看月令本气五行是否透出。
                // 若不透则以月令所藏本气取格；

                // 若只透阴干或只透阳干则以所透之物取格。
                if (isset($temp[$this->param['wuxing'][$yue_benqi]]))
                {
                    if (
                        (isset($temp[$this->param['wuxing'][$yue_benqi]][0])
                            && !isset($temp[$this->param['wuxing'][$yue_benqi]][1]))
                        || (isset($temp[$this->param['wuxing'][$yue_benqi]][1])
                            && !isset($temp[$this->param['wuxing'][$yue_benqi]][0]))
                    )
                    {
                        $geju = $this->param['shishen'][$temp[$this->param['wuxing'][$yue_benqi]]['gan'][0]][$bazi[5]] . '格';
                    }
                } else
                {
                    $geju = $this->param['shishen'][$yue_benqi][$bazi[5]] . '格';
                }
                foreach ($temp as $w => $t)
                {
                    // 若透阴阳两干则参照第二步中蓝字部分；
                    if (isset($t[0]) && isset($t[1]) && count($temp) == 1)
                    {
                        // 正官七杀同在则取七杀格，正财偏财同现则以月令所藏为准，
                        // 正印偏印同现也以月令所藏为准，食伤同现则取伤官格；
                        $_shishen = [];
                        foreach ($t['gan'] as $gan)
                        {
                            $_shishen[] = $this->param['shishen'][$gan][$bazi[5]];
                        }
                        if (in_array('七杀', $_shishen) && in_array('正官', $_shishen))
                        {
                            $geju = '七杀格';
                        } elseif (in_array('正财', $_shishen) || in_array('偏财', $_shishen))
                        {
                            // 同在以月令所藏为准
                            if (in_array('正财', $_shishen) && in_array('偏财', $_shishen))
                            {
                                foreach ($canggan as $cg)
                                {
                                    if ($this->param['shishen'][$cg][$bazi[5]] == '正财') $geju = '正财格';
                                    if ($this->param['shishen'][$cg][$bazi[5]] == '偏财') $geju = '偏财格';
                                }
                            } else
                            {
                                $geju = $this->param['shishen'][0] . '格';
                            }
                        } elseif (in_array('正印', $_shishen) && in_array('偏印', $_shishen))
                        {
                            $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . '格';
                        } elseif (in_array('食神', $_shishen) && in_array('伤官', $_shishen))
                        {
                            $geju = '伤官格';
                        }

                    }
                    if ($geju) break;
                }
            }
        }
        // 戊己日主生在辰戌丑未月份
        if ($geju === '')
        {
            // 若月支为辰
            if ($bazi[4] == '辰')
            {
                // 它支有申或子或亥，以癸水定格，前面加“通变”二字
                if (
                    in_array($bazi[2], ['申', '子', '亥'])
                    || in_array($bazi[6], ['申', '子', '亥'])
                    || in_array($bazi[8], ['申', '子', '亥'])
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['癸'][$bazi[5]] . '格';
                } // 它支同时有寅卯二字，则“七杀格”，加通变二字
                elseif (
                    ($bazi[2] == '寅' && ($bazi[6] == '卯' || $bazi[8] == '卯'))
                    || ($bazi[2] == '卯' && ($bazi[6] == '寅' || $bazi[8] == '寅'))
                    || ($bazi[6] == '寅' && ($bazi[2] == '卯' || $bazi[8] == '卯'))
                    || ($bazi[6] == '卯' && ($bazi[2] == '寅' || $bazi[8] == '寅'))
                    || ($bazi[8] == '寅' && ($bazi[2] == '卯' || $bazi[6] == '卯'))
                    || ($bazi[8] == '卯' && ($bazi[2] == '寅' || $bazi[6] == '寅'))
                )
                {
                    $str = '通变';
                    $geju = '七杀格';
                }
            } // 若月支为戌
            elseif ($bazi[4] == '戌')
            {
                // 它支有寅或午或巳，则以丁火定格，加通变二字
                if (
                    in_array($bazi[2], ['寅', '午', '巳'])
                    || in_array($bazi[6], ['寅', '午', '巳'])
                    || in_array($bazi[8], ['寅', '午', '巳'])
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['丁'][$bazi[5]] . '格';
                } // 它支同时有申酉二字，则“伤官格”，加通变二字
                elseif (
                    ($bazi[2] == '申' && ($bazi[6] == '酉' || $bazi[8] == '酉'))
                    || ($bazi[2] == '酉' && ($bazi[6] == '申' || $bazi[8] == '申'))
                    || ($bazi[6] == '申' && ($bazi[2] == '酉' || $bazi[8] == '酉'))
                    || ($bazi[6] == '酉' && ($bazi[2] == '申' || $bazi[8] == '申'))
                    || ($bazi[8] == '申' && ($bazi[2] == '酉' || $bazi[6] == '酉'))
                    || ($bazi[8] == '酉' && ($bazi[2] == '申' || $bazi[6] == '申'))
                )
                {
                    $str = '通变';
                    $geju = '伤官格';
                }
            } // 若月支为丑
            elseif ($bazi[4] == '丑')
            {
                // 它支有巳或酉或申，则“伤官格”，加通变二字
                if (
                    in_array($bazi[2], ['酉', '申', '巳'])
                    || in_array($bazi[6], ['酉', '申', '巳'])
                    || in_array($bazi[8], ['酉', '申', '巳'])
                )
                {
                    $str = '通变';
                    $geju = '伤官格';
                } // 它支同时有亥子二字，则以癸水定格，加通变二字
                elseif (
                    ($bazi[2] == '亥' && ($bazi[6] == '子' || $bazi[8] == '子'))
                    || ($bazi[2] == '子' && ($bazi[6] == '亥' || $bazi[8] == '亥'))
                    || ($bazi[6] == '亥' && ($bazi[2] == '子' || $bazi[8] == '子'))
                    || ($bazi[6] == '子' && ($bazi[2] == '亥' || $bazi[8] == '亥'))
                    || ($bazi[8] == '亥' && ($bazi[2] == '子' || $bazi[6] == '子'))
                    || ($bazi[8] == '子' && ($bazi[2] == '亥' || $bazi[6] == '亥'))
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['癸'][$bazi[5]] . '格';
                }
            } // 若月支为未
            elseif ($bazi[4] == '未')
            {
                // 它支有亥或卯或寅，则“七杀格”，加通变二字
                if (
                    in_array($bazi[2], ['亥', '卯', '寅'])
                    || in_array($bazi[6], ['亥', '卯', '寅'])
                    || in_array($bazi[8], ['亥', '卯', '寅'])
                )
                {
                    $str = '通变';
                    $geju = '七杀格';
                } // 它支同时有巳午二字，则以丁火定格，加通变二字
                elseif (
                    ($bazi[2] == '巳' && ($bazi[6] == '午' || $bazi[8] == '午'))
                    || ($bazi[2] == '午' && ($bazi[6] == '巳' || $bazi[8] == '巳'))
                    || ($bazi[6] == '巳' && ($bazi[2] == '午' || $bazi[8] == '午'))
                    || ($bazi[6] == '午' && ($bazi[2] == '巳' || $bazi[8] == '巳'))
                    || ($bazi[8] == '巳' && ($bazi[2] == '午' || $bazi[6] == '午'))
                    || ($bazi[8] == '午' && ($bazi[2] == '巳' || $bazi[6] == '巳'))
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['丁'][$bazi[5]] . '格';
                }
            }
        }
        // 以上皆非则“无主格”
        if ($geju === '')
        {
            $geju = '无主格';
        }
        /**
         * 八字格局分格
         */
        $fenge = '';
        // 检测格局成败及用神划分，定分格
        if ($geju == '正官格')
        {

        } elseif ($geju == '正财格' || $geju == '偏财格')
        {

        } elseif ($geju == '七杀格')
        {

        } elseif ($geju == '正印格' || $geju == '偏印格')
        {

        } elseif ($str == '杂气' && $geju == '食神格')
        {

        } elseif ($geju == '伤官格')
        {

        } elseif ($geju == '建禄格')
        {

        } elseif ($geju == '月劫格')
        {

        } elseif ($geju == '月刃格')
        {

        }
        if ($geju == '无主格') $str = '';

        return $str . $geju . $fenge;
    }

    /**
     * 获取十神关系表
     * @return mixed
     */
    public function getShishenParam()
    {
        return $this->param['shishen'];
    }
}
